Skip to content

Project base to create web Rest API with Python over FastAPI framework.

License

Notifications You must be signed in to change notification settings

pantaflex44/PythonBaseApi

Repository files navigation

PythonBaseApi v1.1

GitHub issues GitHub last commit GitHub commit activity GitHub license GitHub stars GitHub forks

Project base to create web Rest API with Python over FastAPI framework.


Use project

Some requirements are wanted on your system:

- Python 3
- Pip 3
- Mysql Server 5.7
- git

WARNING : cert.pem and key.pem are required to use SSL with uvicorn server.



Automated installation


Download the latest PythonBaseApi installer

$ wget https://raw.githubusercontent.com/pantaflex44/PythonBaseApi/v1/pba-latest-installer.sh
$ chmod +x pba-latest-installer.sh

Then, run the installer

$ ./pba-latest-installer.sh

Your done! Enjoy with your new API project!



Manual installation


Clone the project

$ git clone https://github.com/pantaflex44/PythonBaseApi.git
$ cd PythonBaseApi
$ rm -rf .git
$ git init

Install Python environment

$ python3 -m venv ./venv
$ source ./venv/bin/activate
$ pip3 install -r requirements.txt

Install database and faker data

$ python3 -m api --db-install

Set personnal parameters

All parameters found in core\settings.py

To generate new JWT secret key:

$ python -m api --generate-jwt-secret

Use this API as script

$ python -m api

To naviguate in the API doc, use your browser at https://127.0.0.1:8443/latest/docs

The default credentials is:

- Username: administrator
- Password: Admin1234!

Deployment

The main entry point to deploy API online is: api:app.

With an uvicorn server, you can use:

$ uvicorn --use-colors --reload --host 127.0.0.1 --port 8443 --ssl-keyfile key.pem --ssl-certfile cert.pem api:app