Steps 1-5 creates a working web framework application.
Steps 6-7 connects to the database
Steps 8-9 creates the application (endpoints, services to interact with database, password hashing)
Steps 10 adds authentication and authorization using JWT
- Initialize
Python
environmentenv
withpython3.9 -m venv env
.
requirements.txt
will have all the third party dependencies you need for your project.
4. Create a main Python class, main.py
and add code from https://fastapi.tiangolo.com/#:~:text=Create%20a%20file,with to test
- The
app
instance created fromFastAPI
is our web framework. - Gives us endpoints via
@app
decorator. - We can get
.post
,.get
,.put
,.delete
,.patch
, etc.
- Module Name:
uvicorn
. - Parameters:
main:app --reload
. - Go to http://127.0.0.1:8000 to see if the app is running.
- Usually a right click on
Database
showsCreate >
which then prompts a modal to create a new database. - Name it whatever you want and
Save
.
- Create a new
.env
folder that will house all the environment variables.- Usually this file will have secrets coming from
AWS
, other areas.
- Usually this file will have secrets coming from
- Create a
config.py
file that will house all the.env
values. - Create a
session.py
file that creates new sessions. - Create a
base_class.py
that will have@as_declarative
which grants us to manipulate tables. - Create a
base.py
file that will serve as a bootstrap. - In
main.py
importBase
fromtables.py
to create the tables,bind
runs the engine.- the
.metadata
object is NOT offered in autocomplete, but is available. - I learned that the classes we want to be tables *that extended
Base
) must be in thetables.py
file- if not, the tables does not get created.
- the
users
jobs