Skip to content

EGillani/Post_Application_FASTAPI

Repository files navigation

Requirements

Python 3.6+

Postgres/PgAdmin (For Database)

Docker for Desktop (Optional)

FastAPI stands on the shoulders of giants:

Installation

Create a virtual environment.

$ py -3 -m venv your_env_name 

Invoke the virtual environment.

$ your_env_name\Scripts\activate.bat

Download all packages found in the requirements.txt file

$ pip install -r requirements.txt

Make a .env file (use .env.sample as an example). Fill in the values.

$ touch .env

Run it

Run the server with:

$ uvicorn app.main:app --reload

INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [28720]
INFO:     Started server process [28722]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
About the command uvicorn main:app --reload...

The command uvicorn app.main:app refers to:

  • main: the file main.py (the Python "module") inside the directory app.
  • app: the object created inside of main.py with the line app = FastAPI().
  • --reload: make the server restart after code changes. Only do this for development.

Check it

Open your browser at http://127.0.0.1:8000.

You will see the JSON response as:

{"message": "Welcome to my post application"}

Interactive API docs

Now go to http://127.0.0.1:8000/docs.

You will see the automatic interactive API documentation (provided by Swagger UI):

Alternative API docs

And now, go to http://127.0.0.1:8000/redoc.

You will see the alternative automatic documentation (provided by ReDoc):

About

Utilizing FastAPI framework and launched on a Droplet/VM in DigitalCloud. Application uses pydantic models, postgres, sqlalchemy, env variables, etc. Still have to improve many things

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages