A minimal REST API made using Flask & SQL Alchemy. Products API using Python Flask, SQL Alchemy and Marshmallow.
Made with ❤️ using Flask Framework
🏠 Homepage
- REST API
- SQLite database
- SQLAlchemy ORM
# Clone the sources
# Virtualenv modules installation (Windows based systems)
# virtualenv --no-site-packages env
# .\env\Scripts\activate.bat
# Virtualenv modules installation (Unix based systems)
virtualenv --no-site-packages env
source env/bin/activate
# Install requirements
pip3 install -r requirements.txt
# Set the FLASK_APP environment variable
# (Unix/Mac) export FLASK_APP=run.py
# (Windows) set FLASK_APP=run.py
# (Powershell) $env:FLASK_APP = ".\run.py"
export FLASK_APP=run.py
```sh
# Set up the DEBUG environment
# (Unix/Mac) export FLASK_ENV=development
# (Windows) set FLASK_ENV=development
# (Powershell) $env:FLASK_ENV = "development"
export FLASK_ENV=development
# Run the application
# --host=0.0.0.0 - expose the app on all network interfaces (default 127.0.0.1)
# --port=5000 - specify the app port (default 5000)
flask run --host=0.0.0.0 --port=5000
# Access the app in browser: http://127.0.0.1:5000/
- GET
/products
- GET
/products/:id
- POST
/products
- PUT
/products/:id
- DELETE
/products/:id
The app has a basic configuration to be executed in Docker, Gunicorn, and Waitress.
Docker execution
The application can be easily executed in a docker container. The steps:
Get the code
cd flask-api
Start the app in Docker
sudo docker-compose pull && sudo docker-compose build && sudo docker-compose up -d
Visit http://localhost:5005
in your browser. The app should be up & running.
Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX.
Install using pip
pip install gunicorn
Start the app using gunicorn binary
gunicorn --bind 0.0.0.0:8001 run:app
# Serving on http://localhost:8001
Visit http://localhost:8001
in your browser. The app should be up & running.
Waitress (Gunicorn equivalent for Windows) is meant to be a production-quality pure-Python WSGI server with very acceptable performance. It has no dependencies except ones that live in the Python standard library.
Install using pip
pip install waitress
Start the app using waitress-serve
waitress-serve --port=8001 run:app
# Serving on http://localhost:8001
Visit http://localhost:8001
in your browser. The app should be up & running.
- 👤 Alpha Olomi - Website: https://alphaolomi.me Github: @alphaolomi
- All Contributors
pytest test
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.
If you discover any security related issues, please email alphaolomi@gmail.com instead of using the issue tracker.
Give a ⭐️ if this project helped you!
Copyright © 2020 Alpha Olomi.
This project is MIT licensed.