Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/khanhduzz/python-fastapi
Python with FastAPI project
https://github.com/khanhduzz/python-fastapi
Last synced: about 1 month ago
JSON representation
Python with FastAPI project
- Host: GitHub
- URL: https://github.com/khanhduzz/python-fastapi
- Owner: khanhduzz
- Created: 2024-08-27T02:20:46.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-29T10:28:14.000Z (3 months ago)
- Last Synced: 2024-08-29T11:48:16.751Z (3 months ago)
- Language: Python
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python FastAPI
A FastAPI mini application to learn how to use FastAPI with SQLAlchemy and PostGreSQL.
- Admin username: james
- Admin password: depend on your .env setup# Sample Setup
- Create a virtual environment using `virtualenv` module in python.
```bash
# Install module (globally)
pip install virtualenv# Generate virtual environment
virtualenv --python= venv# Activate virtual environment
source venv/bin/activate# Install depdendency packages
pip install -r requirements.txt
```
- Configure `.env` file by creating a copy from `.env.sample`
- Setup a postgres docker container
```bash
docker run -p 5432:5432 --name postgres -e POSTGRES_PASSWORD= -d postgres:14
```
- At `app` directory, run `alembic` migration command. Please make sure your postgres DB is ready and accessible. In case you want to use `SQLite` instead, please be sure to configure the `env.py` file in `alembic` folder to support `batch execution` since `SQLite` does not support `ALTER` command, which is needed to configure the foreign key and establish the indexes.
```bash
# Migrate to latest revison
alembic upgrade head# Dowgragde to specific revision
alembic downgrade# Downgrade to base (revert all revisions)
alembic downgrade base# Create new revision
alembic revision -m
```
- Run `uvicorn` web server from `app` directory (`reload` mode is for development purposes)
```bash
uvicorn main:app --reload
```