AP
app-generator/sample-flask-api-restx
Flask API Sample - Open-Source API Server | AppSeed
Flask API Sample
Simple Flask API Server powered by Flask-RestX, SqlAlchemy, SQLite persistence - Provided by AppSeed.
Features:
Up-to-date dependencies- Simple, intuitive codebase - can be extended with ease.
Flask-restXDockersupport- Free support via email and Discord (1k+ community).
✨ API Definition
| Route | Verb | Info | Status |
|---|---|---|---|
/datas |
GET | return all items | ✔️ |
| POST | create a new item | ✔️ | |
/datas:id |
GET | return one item | ✔️ |
| PUT | update item | ✔️ | |
| DELETE | delete item | ✔️ |
✨ Quick Start in Docker
Get the code
$ git clone https://github.com/app-generator/flask-api-sample.git
$ cd flask-api-sampleStart the app in Docker
$ docker-compose up --build The API server will start using the PORT 5000.
✨ How to use the code
Step #1 - Clone the project
$ git clone https://github.com/app-generator/flask-api-sample.git
$ cd flask-api-sampleStep #2 - create virtual environment using python3 and activate it (keep it outside our project directory)
$ # Virtualenv modules installation (Unix based systems)
$ virtualenv env
$ source env/bin/activate
$
$ # Virtualenv modules installation (Windows based systems)
$ # virtualenv env
$ # .\env\Scripts\activateStep #3 - Install dependencies in virtualenv
$ pip install -r requirements.txtStep #4 - setup
flaskcommand for our app
$ export FLASK_APP=run.py
$ export FLASK_ENV=developmentOr for Windows-based systems
$ (Windows CMD) set FLASK_APP=run.py
$ (Windows CMD) set FLASK_ENV=development
$
$ (Powershell) $env:FLASK_APP = ".\run.py"
$ (Powershell) $env:FLASK_ENV = "development"Step #5 - start test APIs server at
localhost:5000
$ flask runUse the API via POSTMAN or Swagger Dashboard.
✨ Project Structure
api-server-flask/
├── api
│ ├── __init__.py
│ ├── config.py
│ ├── models.py
│ └── routes.py
├── README.md
├── requirements.txt
└── run.pyFlask API Sample - provided by AppSeed App Generator
On this page
Languages
Python93.7%Dockerfile5.1%Shell1.2%
Contributors
MIT License
Created January 31, 2022
Updated December 10, 2023

