Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/app-generator/api-server-flask
Flask API Server - Open-Source API Server | AppSeed
https://github.com/app-generator/api-server-flask
api-server appseed-sample flask flask-api flask-api-sample flask-restapi flask-restx flask-template free-api open-source-api
Last synced: 7 days ago
JSON representation
Flask API Server - Open-Source API Server | AppSeed
- Host: GitHub
- URL: https://github.com/app-generator/api-server-flask
- Owner: app-generator
- License: other
- Created: 2021-07-03T07:14:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-22T08:41:17.000Z (6 months ago)
- Last Synced: 2024-12-29T06:06:54.989Z (14 days ago)
- Topics: api-server, appseed-sample, flask, flask-api, flask-api-sample, flask-restapi, flask-restx, flask-template, free-api, open-source-api
- Language: Python
- Homepage: https://appseed.us/boilerplate-code/
- Size: 62.5 KB
- Stars: 103
- Watchers: 5
- Forks: 35
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- jimsghstars - app-generator/api-server-flask - Flask API Server - Open-Source API Server | AppSeed (Python)
README
## [Flask API Server](https://github.com/app-generator/api-server-flask)
Simple **Flask API Boilerplate** enhanced with `JWT` authentication, `OAuth` via **GitHub**, `SqlAlchemy`, **SQLite** persistence, and deployment scripts via Docker. It has all the `ready-to-use` bare minimum essentials.
- 👉 [Support](https://appseed.us/support/) via **Discord & Email**
- 🚀 [Custom Development Services](https://appseed.us/custom-development/) for `StartUPs`, `Small Businesses`, and `Solo-developers`
> Features:
- ✅ `Up-to-date dependencies`
- ✅ [API Definition](https://docs.appseed.us/boilerplate-code/api-unified-definition) - the unified API structure implemented by this server
- ✅ API powered by `Flask-restX`
- ✅ `JWT Authentication` (login, logout, register) via `Flask-jwt_extended`
- 🆕 `OAuth` for **Github**
- Full-stack ready with [React Soft Dashboard](https://github.com/app-generator/react-soft-ui-dashboard)
- ✅ **Docker**, `Unitary tests`
> Can be used with other [React Starters](https://appseed.us/apps/react) for a complete **Full-Stack** experience:
| [React Node JS Berry](https://appseed.us/product/berry-dashboard/api-server-nodejs/react/) | [React Node Soft Dashboard](https://appseed.us/product/soft-ui-dashboard/api-server-nodejs/react/) | [React Node Horizon](https://appseed.us/product/horizon-ui/api-server-nodejs/) |
| --- | --- | --- |
| [![React Node JS Berry](https://user-images.githubusercontent.com/51070104/176936514-f1bccb21-bafe-4b43-9e4c-b6fe0ec9511d.png)](https://appseed.us/product/berry-dashboard/api-server-nodejs/react/) | [![React Node Soft Dashboard](https://user-images.githubusercontent.com/51070104/176936814-74386559-4e05-43d5-b9a4-8f70ce96a610.png)](https://appseed.us/product/soft-ui-dashboard/api-server-nodejs/react/) | [![React Node Horizon](https://user-images.githubusercontent.com/51070104/174428337-181e6dea-0ad9-4fe1-a35f-25e5fa656a9d.png)](https://appseed.us/product/horizon-ui/api-server-nodejs/)
![Flask API Server - Open-source Flask Starter provided by AppSeed.](https://user-images.githubusercontent.com/51070104/126349643-264d4cf4-6d0b-4c24-8185-adf69409fa4e.png)
## ✨ Quick Start in `Docker`
> Get the code
```bash
$ git clone https://github.com/app-generator/api-server-flask.git
$ cd api-server-flask
```> Start the app in Docker
```bash
$ docker-compose up --build
```The API server will start using the PORT `5000`.
## ✨ Table of Contents
1. [Getting Started](#getting-started)
2. [Project Structure](#project-structure)
3. [Modules](#modules)
4. [Testing](#testing)
## ✨ How to use the code
> **Step #1** - Clone the project
```bash
$ git clone https://github.com/app-generator/api-server-flask.git
$ cd api-server-flask
```
> **Step #2** - create virtual environment using python3 and activate it (keep it outside our project directory)
```bash
$ # Virtualenv modules installation (Unix based systems)
$ virtualenv env
$ source env/bin/activate
$
$ # Virtualenv modules installation (Windows based systems)
$ # virtualenv env
$ # .\env\Scripts\activate
```
> **Step #3** - Install dependencies in virtualenv
```bash
$ pip install -r requirements.txt
```
> **Step #4** - setup `flask` command for our app
```bash
$ export FLASK_APP=run.py
$ export FLASK_ENV=development
```For **Windows-based** systems
```powershell
$ (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** - Create a new `.env` file using sample `env.sample`
The meaning of each variable can be found below:
- `DEBUG`: if `True` the app runs in develoment mode
- For production value `False` should be used
- `SECRET_KEY`: used in assets management
- `GITHUB_CLIENT_ID`: For GitHub social login
- `GITHUB_SECRET_KEY`: For GitHub social login
> **Step #6** - start test APIs server at `localhost:5000`
```bash
$ flask run
```Use the API via `POSTMAN` or Swagger Dashboard.
![Flask API Server - Swagger Dashboard.](https://user-images.githubusercontent.com/51070104/141950891-ea315fca-24c2-4929-841c-38fb950a478d.png)
## ✨ Project Structure
```bash
api-server-flask/
├── api
│  ├── config.py
│  ├── __init__.py
│  ├── models.py
│  └── routes.py
├── Dockerfile
├── README.md
├── requirements.txt
├── run.py
└── tests.py
```
## ✨ API
For a fast set up, use this `POSTMAN` file: [api_sample](https://github.com/app-generator/api-unified-definition/blob/main/api.postman_collection.json)
> **Register** - `api/users/register` (**POST** request)
```
POST api/users/register
Content-Type: application/json{
"username":"test",
"password":"pass",
"email":"[email protected]"
}
```
> **Login** - `api/users/login` (**POST** request)
```
POST /api/users/login
Content-Type: application/json{
"password":"pass",
"email":"[email protected]"
}
```
> **Logout** - `api/users/logout` (**POST** request)
```
POST api/users/logout
Content-Type: application/json
authorization: JWT_TOKEN (returned by Login request){
"token":"JWT_TOKEN"
}
```
## ✨ Testing
Run tests using `pytest tests.py`
---
**[Flask API Server](https://github.com/app-generator/api-server-flask)** - provided by [AppSeed](https://appseed.us)