A REST API boilerplate project using fastapi
and dataset
, setup for easy deployment on heroku
.
Clone the repo
$ git clone https://github.com/Ju99ernaut/gjs-api.git
$ cd superfast-api
Create virtual enviroment
$ python -m venv venv
Activate virtual enviroment
Linux/MacOS: source venv/bin/activate
Windows: .\venv\Scripts\Activate.ps1
or .\venv\Scripts\activate
Install dependencies
$ pip install -r requirements.txt`
Run
$ python api/main.py
The API should now be available at http://127.0.0.1:8000
and the API documentation will be available at /docs
or /redoc
.
Depending on the type of database backend, you may also need to install a database specific driver package. For MySQL, this is MySQLdb, for Postgres its psycopg2. SQLite support is integrated into Python.
On heroku you may come across the sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres
, you can avoid it by replacing postgres://...
with postgresql://...
in your connection url, or you can handle for it programmatically using something like:
url = url.replace("postgres:", "postgresql:")
MIT