Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FastAPI (API) Server - Open-Source project | AppSeed

NotificationsYou must be signed in to change notification settings

app-generator/api-server-fastapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI (API) Server

SimpleFastAPI Starter enhanced withJWT authentication,OAuth viaGitHub,SqlAlchemy,SQLite persistence and deployment scripts via Docker - Actively supported byApp-Generator.

👉 For moreFastAPI Resources please access:


Product Roadmap &Features:

StatusIteminfo
Up-to-date Dependencies-
JWT Authentication(login, logout, register) viaoauth2
OAuthvia GitHub`
PersistenceSQLite,MySql
Docker-
Unitary testsminimal suite

✨ Quick Start inDocker

Get the code

$ git clone https://github.com/app-generator/api-server-fastapi.git$cd api-server-fastapi

Start the app in Docker

$ docker-compose up --build

Note: Theenv.sample file will be used to set the environment variables for the docker container. Make sure to set them as needed.The API server will start using the PORT5000.


✨ Table of Contents

  1. Getting Started
  2. Project Structure
  3. Modules
  4. Testing

✨ How to use the code

Step #1 - Clone the project

$ 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)

$# 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

$ pip install -r requirements.txt

Step #5 - Create a new.env file using sampleenv.sample

The meaning of each variable can be found below:

  • DEBUG: ifTrue the app runs in develoment mode
    • For production valueFalse should be used
  • SECRET_KEY: used in assets management
  • GITHUB_CLIENT_ID: For GitHub social login
  • GITHUB_SECRET_KEY: For GitHub social login
  • DATABASE_HOSTNAME: For Mysql databse
  • DATABASE_PORT: For Mysql databse
  • DATABASE_PASSWORD: For Mysql databse
  • DATABASE_NAME: For Mysql databse
  • DATABASE_USERNAME: For Mysql databse
  • ALGORITHM: For JWT Tokens
  • ACCESS_TOKEN_EXPIRE_MINUTES: For JWT Tokens

Step #6 - start test APIs server atlocalhost:5000

$ uvicorn src.app:app

Use the API viaPOSTMAN or Swagger Dashboard.

Flask API Server - Swagger Dashboard.


✨ Project Structure

api-server-flask/├── src    ├── helpers        ├── database.py        └── utils.py    ├── routers        ├── users.py│   ├── __init__.py│   ├── app.py│   ├── config.py│   ├── models.py│   ├── oatuh2.py│   └── schemas.py├── tests    ├── __init__.py    ├── conftest.py    ├── database.py    └── test_users.py├── Dockerfile├── docker-compose.yaml├── README.md├── requirements.txt├── run.py

✨ API

For a fast set up, use thisPOSTMAN file:api_sample

Register -api/users/register (POST request)

POST api/users/registerContent-Type: application/json{    "username":"test",    "password":"pass",     "email":"test@appseed.us"}

Login -api/users/login (POST request)

POST /api/users/loginContent-Type: application/json{    "password":"pass",     "email":"test@appseed.us"}

Logout -api/users/logout (POST request)

POST api/users/logoutContent-Type: application/jsonauthorization: JWT_TOKEN (returned by Login request){    "token":"JWT_TOKEN"}

✨ Testing

Run tests usingpytest tests.py



FastAPI (API) Server - Open-source eCommerce Starter provided byApp-Generator.

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp