Python Rest API scaffold built on top of Flask and Flask Restful
As this package is not available on pypi, it can only be cloned.
> git clone https://github.com/Peter2962/helium.git
> cd helium
> cp .env.example .env
> pip install -r requirements.txt
Note: Only MySQL database is supported at the moment. The database can be configured in the .env file.
MYSQL_HOST=None MYSQL_USERNAME=None MYSQL_PASSWORD=None MYSQL_DATABASE=None
The .env file also contains APP_PORT and APP_HOST env variables. This is where you set your host and port that the app will make use of.
Also note that the APP_SECRET needs to be set for jwt implementation to work.
Middlewares are located in the /middlewares directory. You can create a new middleware and register it in config.py -> middlewares config option. Middlewares are loaded into app automatically
Models are located in the /models directory. You can create a new model and register it in config.py -> models config option Models are loaded into app automatically
All routes are defined in config.py -> routes_mapping. The routes_mapping variable is a list of dicts and each dict defines a single route.
Each dict contains three keys:
- path - Route path
- resource - The controller and method that will be called for the defined route
- method - Request method that is allowed for a route
An example route:
{
'path': '/api',
'resource': 'ApiController.getData',
'method': 'GET'
}
> python main.py