Udacity
Courses
Content
- SQL
- ORM
- python
- Postgres
- Json
- Flask
- Ninja
- HTTP
- REST
- CORS
- API design
- cURL
- testing
- documentation
- IT security
- Postman
- Authentication patterns
- Auth0
Full Stack Web Developer
C:\Uwes\python\UdacityFullWebDeveloper
Authorization
- signup account at Auth0 with 'uwe.heuer@eon.com' <La><STANDARD><La>
- Tenant Domain uweheuer.eu.auth0.com
- login with https://uweheuer.eu.auth0.com/authorize?audience=test1&response_type=token&client_id=VHZzXYrZGqsMviwYOBOR9mBS6pYm23Fu&redirect_uri=https://127.0.0.1:8080/login-results
- audience is the API identifier
- clientid is the application id
- the pattern is
GET https://YOUR_DOMAIN/authorize? audience=API_IDENTIFIER& scope=SCOPE& response_type=code& client_id=YOUR_CLIENT_ID& redirect_uri=https://YOUR_APP/callback& state=STATE
- after authentification the callback URL is called with a JWT
$env:FLASK_APP = "app.py" flask run --reload
- added user 'uwe.heuer@gmail.com' with <La><STANDARD><La> for authorization test
- login for authorization test with https://uweheuer.eu.auth0.com/authorize?audience=ptest1&response_type=token&client_id=hB4rJzWWIAYdDLBATjL8UvnUdITad42H&redirect_uri=https://127.0.0.1:8080/login-results. This will call the redirect url with the token appended as a get parameter.
Coffee Shop App
Solutions
Backend Installation
- setup an AWS instance
sudo apt install python3.8-venv
- create directory \Uwes\python\UdacityFullWebDeveloper with sudo
sudo git clone https://github.com/udacity/FSND.git
- cd backend
sudo apt-get install python-dev sudo apt-get install gcc sudo python3 -m venv venv sudo chown -R ubuntu:ubuntu venv/ source ./venv/bin/activate pip install wheel deactivate venv
Running the Backend
cd /Uwes/python/UdacityFullWebDeveloper/FSND/projects/03_coffee_shop_full_stack/starter_code/backend export FLASK_APP=api.py; source ./venv/bin/activate cd /src flask run --reload --port=5321 --host=0.0.0.0 // test http://54.212.123.129:5321/drinks // if CTRL + C does not terminate the process netstat -tulpen sudo kill -9 <PID>
Running the Frontend
cd C:\Uwes\python\UdacityFullWebDeveloper\FSND\projects\03_coffee_shop_full_stack\starter_code\frontend ionic serve // test it with http://localhost:8100
Implementation
- implement /drinks in
api.pyw/o any access check
- Create new API 'Coffee Shop' with ID (Audience) 'coffee-shop' by the Auth0 account (see above) and enable RBAC and select 'Add Permission to token'
- add permissions to the API 'Coffee Shop'
- get:drinks
- get:drinks-detail
- post:drink
- patch:drink
- delete:drink
- create roles 'Barista' (get:drinks, get:drinks-detail) and 'Manager' and assign permissions for API 'Coffee Shop'
- assign role 'Manager' to user 'uwe.heuer@eon.com' and 'Barista' to user 'uwe.heuer@gmail.com'
- test public key with https://uweheuer.eu.auth0.com/.well-known/jwks.json
- implement missing methods in
/auth/auth.py
- implement /drinks-detail in api.py with @requires_auth
API Apps
$env:FLASK_APP = "flaskr" // folder to look for the init file $env:FLASK_ENV = "development" // automatically restart of server in case of changes
pip install flask_cors
// extract origin (see below) // from 1_Requests_Starter/readme.md cd backend python -m venv venv // select virtual env interpreter in VCS by Ctrl+Shift+P // open new terminal in VCS which executes the activate script pip install -r requirements.txt // decommented #psycopg2-binary==2.8.2, because compilation with VC++ fails psql.exe -h uweheuer.spdns.de -U postgres postgres \i setup.sql \psql.exe -h uweheuer.spdns.de -U student -d bookshelf -f books.psql pip install psycopg2-binary // replace C:\Uwes\python\UdacityFullWebDeveloper\cd0037-API-Development-and-Documentation-exercises-master\1_Requests_Starter\backend\venv\Lib\site-packages\sqlalchemy\util\compat.py // row 331 time_func = time.clock -> time_func = time.time python -m flask run
Origin
- https://github.com/udacity/cd0037-API-Development-and-Documentation-exercises
- C:\Uwes\python\UdacityFullWebDeveloper\cd0037-API-Development-and-Documentation-exercises-master.zip
Trivia App
cd C:\Uwes\python\UdacityFullWebDeveloper\FSND\projects\02_trivia_api\starter\backend
python -m venv venv .\venv\Scripts\activate // decommented #psycopg2-binary==2.8.2, because compilation with VC++ fails pip install -r requirements.txt C:\Uwes\Programme\PostgreSQL\12\bin\psql.exe -h uweheuer.spdns.de -U postgres postgres CREATE DATABASE trivia; CREATE USER trivia WITH ENCRYPTED PASSWORD 'trivia'; GRANT ALL PRIVILEGES ON DATABASE trivia TO trivia; CREATE DATABASE trivia_test; CREATE USER trivia_test WITH ENCRYPTED PASSWORD 'trivia_test'; GRANT ALL PRIVILEGES ON DATABASE trivia_test TO trivia_test; C:\Uwes\Programme\PostgreSQL\12\bin\psql -U trivia -h uweheuer.spdns.de -f trivia.psql trivia C:\Uwes\Programme\PostgreSQL\12\bin\psql -U trivia_test -h uweheuer.spdns.de -f trivia.psql trivia_test // replace in C:\Uwes\python\UdacityFullWebDeveloper\FSND\projects\02_trivia_api\starter\backend\venv\Lib\site-packages\sqlalchemy\util\compat.py row 331 #time_func = time.clock time_func = time.time C:\Uwes\python\UdacityFullWebDeveloper\FSND\projects\02_trivia_api\starter\frontend> npm install // to run the app .\venv\Scripts\activate $env:FLASK_APP = "flaskr" // folder to look for the init file $env:FLASK_ENV = "development" // automatically restart of server in case of changes $env:DB_HOST = "uweheuer.spdns.de:5432" python -m flask run C:\Uwes\python\UdacityFullWebDeveloper\FSND\projects\02_trivia_api\starter\frontend> npm start
// to run the tests python .\test_flaskr.py
Upload for Check
pip freeze > requirements.txt
Solutions
- https://github.com/alexsandberg/trivia_api
- https://github.com/AlaaSayed794/Trivia-App/tree/master/backend
ToDo App
Fyyur App
- run as prepartion (rest was already installed for lesson)
pip3 install virtualenv npm install bootstrap@3 // creating .env file for VSC debugging
- execute Development Setup from GitHub
- with psql
create database fyyur; create user fyyur with encrypted password 'fyyur'; grant all privileges on database fyyur to fyyur;
- in
C:\Uwes\python\UdacityFullWebDeveloper\FSND\projects\01_fyyur\starter_code
python -m virtualenv env
- to run the app
C:\Uwes\python\UdacityFullWebDeveloper\FSND\projects\01_fyyur\starter_code>.\env\Scripts\activate pip install Flask-migrate // one-time pip3 install psycopg2 // one-time flask db init // one-time
flask db migrate // if needed
C:\Uwes\python\UdacityFullWebDeveloper\FSND\projects\01_fyyur\starter_code>.\env\Scripts\activate #$env:FLASK_ENV = "development" // moved to .env file python .\app.py http://127.0.0.1:5000/
Origin
Solutions
- https://github.com/WenkaiTan/FSND/tree/master/projects/01_fyyur/starter_code
- fyyur-master.zip
- fyyur-artist-booking-master.zip
Running System
AWS Project
Create Admin User for AWS CLI
- IAM Dashboard
- no tags
- create user
- download CSV to
C:\Uwes\python\UdacityFullWebDeveloper\AWS\ this adds sections in
C:\Users\U1728\.aws\configandC:\Users\U1728\.aws\credentials.- check configuration by
- S3 Dashboard
Issues
- AWS Portal screen shots out-dated
- description out-dated and not complete for Windows