A minimal FastAPI implementation for Django !

Overview

Caution!!!

This project is in early developing stage. So use it at you own risk.

Bug reports / Fix PRs are welcomed.

Installation

pip install django-mini-fastapi

Live demo provided by Gitpod

Click the button below and launch a free live demo server via Gitpod

Gitpod ready-to-code

If the button doesn't show up, you clould also use below link directly

https://gitpod.io/#https://github.com/tokikanno/django-mini-fastapi

After Gitpod launched, wait a while for the auto execution of make intro command Then you could using VScode remote explorer for opening the intro demo server in your browser.

image

What is django-mini-fastapi ?

A minimal FastAPI implementation for Django !

This project reused more than 95% codes from FastAPI. I just did minimal necessary modifications for making it working under Django.

So basicly you can read documents from FastAPI for knowing how to use this module. (Except features metioned in Features currently not work section) The difference between django-mini-fastapi and FastAPI is how you import and mount it.

# This is how you declear OpenAPI endpoint in FastAPI
from typing import Optional

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
    return {"item_id": item_id, "q": q}

Above is the quick start sample in FastAPI document, which should be re-written like below

# This is how you do the same thing in django-mini-fastapi
from typing import Optional
from django_mini_fastapi import OpenAPI

app = OpenAPI()

@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
    return {"item_id": item_id, "q": q}

And you should mount the API endpoint via Django url pattern mechanism by calling app.as_django_url_pattern()

urlpatterns = [
    # use as_django_url_pattern() for mounting API endpoint into Django url parser
    app.as_django_url_pattern(),
]

And usually you won't want to mount API endpoint in / for a Django project. You could pass the root_path parameter to OpenAPI init function for changing the mount point.

app = OpenAPI(root_path='/api')

For fully working example script, please see demo/intro.py

You can also type

make intro

for starting test intro server.

Why do you make this? Can't you just use FastAPI directly?

I'm a big fan of FastAPI. It's elegant and saves lots of doc maintaince & API spec communication costs for me.

But I'm maintaing huge legacy projects built by Django framework. It will take massive resources for porting it onto FastAPI.

So I decided to modifiy FastAPI for making it working under Django, then I could instantly get the benefits from FastAPI without doing migrations for my legacy projects.

Who should use this?

People who like the way FastAPI works but don't want to do full system rewrite from Django to FastAPI

Features currently work

  • Auto OpenAPI schema/document generation from Python function declaration
  • Auto request parameter validation
  • Dependencies system

Features currently not work

  • Auto OpenAPI parameters parsing & processing
    • Callback function delcearation (WIP)
    • Security scopes (Evaluating/Planning)
  • WebSocket endpoints (Not in priority)
  • Backgournd tasks (Not in priority)
Owner
toki
toki
๐Ÿž A debug toolbar for FastAPI based on the original django-debug-toolbar. ๐Ÿž

Debug Toolbar ๐Ÿž A debug toolbar for FastAPI based on the original django-debug-toolbar. ๐Ÿž Swagger UI & GraphQL are supported. Documentation: https:/

Dani 74 Dec 30, 2022
Keycloack plugin for FastApi.

FastAPI Keycloack Keycloack plugin for FastApi. Your aplication receives the claims decoded from the access token. Usage Run keycloak on port 8080 and

Elber 4 Jun 24, 2022
Cbpa - Coinbase Pro Automation for buying your favourite cryptocurrencies

cbpa Coinbase Pro Automation for making buy orders from a default bank account.

Anthony Corletti 3 Nov 27, 2022
A minimum reproducible repository for embedding panel in FastAPI

FastAPI-Panel A minimum reproducible repository for embedding panel in FastAPI Follow either This Tutorial or These steps below โ†“โ†“โ†“ Clone the reposito

Tyler Houssian 15 Sep 22, 2022
FastAPI Auth Starter Project

This is a template for FastAPI that comes with authentication preconfigured.

Oluwaseyifunmi Oyefeso 6 Nov 13, 2022
Prometheus exporter for Starlette and FastAPI

starlette_exporter Prometheus exporter for Starlette and FastAPI. The middleware collects basic metrics: Counter: starlette_requests_total Histogram:

Steve Hillier 225 Jan 05, 2023
๐Ÿš€ Cookiecutter Template for FastAPI + React Projects. Using PostgreSQL, SQLAlchemy, and Docker

FastAPI + React ยท A cookiecutter template for bootstrapping a FastAPI and React project using a modern stack. Features FastAPI (Python 3.8) JWT authen

Gabriel Abud 1.4k Jan 02, 2023
API Simples com python utilizando a biblioteca FastApi

api-fastapi-python API Simples com python utilizando a biblioteca FastApi Para rodar esse script sรฃo necessรกrias duas bibliotecas: Fastapi: Comando de

Leonardo Grava 0 Apr 29, 2022
Dead simple CSRF security middleware for Starlette โญ and Fast API โšก

csrf-starlette-fastapi Dead simple CSRF security middleware for Starlette โญ and Fast API โšก Will work with either a input type="hidden" field or ajax

Nathaniel Sabanski 9 Nov 20, 2022
FastAPI IPyKernel Sandbox

FastAPI IPyKernel Sandbox This repository is a light-weight FastAPI project that is meant to provide a wrapper around IPyKernel interactions. It is in

Nick Wold 2 Oct 25, 2021
MS Graph API authentication example with Fast API

MS Graph API authentication example with Fast API What it is & does This is a simple python service/webapp, using FastAPI with server side rendering,

Andrew Hart 4 Aug 11, 2022
๐Ÿƒ A comprehensive monitoring and alerting solution for the status of your Chia farmer and harvesters.

chia-monitor A monitoring tool to collect all important metrics from your Chia farming node and connected harvesters. It can send you push notificatio

Philipp Normann 153 Oct 21, 2022
Keepalive - Discord Bot to keep threads from expiring

keepalive Discord Bot to keep threads from expiring Installation Create a new Di

Francesco Pierfederici 5 Mar 14, 2022
This repository contains learning resources for Python Fast API Framework and Docker

This repository contains learning resources for Python Fast API Framework and Docker, Build High Performing Apps With Python BootCamp by Lux Academy and Data Science East Africa.

Harun Mbaabu Mwenda 23 Nov 20, 2022
Deploy/View images to database sqlite with fastapi

Deploy/View images to database sqlite with fastapi cd realistic Dependencies dat

Fredh Macau 1 Jan 04, 2022
:rocket: CLI tool for FastAPI. Generating new FastAPI projects & boilerplates made easy.

Project generator and manager for FastAPI. Source Code: View it on Github Features ๐Ÿš€ Creates customizable project boilerplate. Creates customizable a

Yagiz Degirmenci 1k Jan 02, 2023
SuperSaaSFastAPI - Python SaaS Boilerplate for building Software-as-Service (SAAS) apps with FastAPI, Vue.js & Tailwind

Python SaaS Boilerplate for building Software-as-Service (SAAS) apps with FastAP

Rudy Bekker 31 Jan 10, 2023
์Šคํƒ€ํŠธ์—… ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ

์Šคํƒ€ํŠธ์—… ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ ๅคง ๋ฐ•๋žŒํšŒ Seed ~ Series B์— ์žˆ๋Š” ์Šคํƒ€ํŠธ์—…์„ ์œ„ํ•œ ์ฑ„์šฉ์ •๋ณด ํŽ˜์ด์ง€์ž…๋‹ˆ๋‹ค. Back-end, Frontend, Mobile ๋“ฑ ๊ฐœ๋ฐœ์ž๋ฅผ ๋Œ€์ƒ์œผ๋กœ ์ง„ํ–‰ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ์Šคํƒ€ํŠธ์—…์— ์ข…์‚ฌํ•˜์‹œ๋Š” ๋ถ„๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์ฑ„์šฉ ๊ด€๋ จ ์ •๋ณด๋ฅผ ์•Œ๊ณ  ๊ณ„์‹œ๋‹ค๋ฉด

JuHyun Lee 58 Dec 14, 2022
FastAPI-Amis-Admin is a high-performance, efficient and easily extensible FastAPI admin framework. Inspired by django-admin, and has as many powerful functions as django-admin.

็ฎ€ไฝ“ไธญๆ–‡ | English ้กน็›ฎไป‹็ป FastAPI-Amis-Admin fastapi-amis-adminๆ˜ฏไธ€ไธชๆ‹ฅๆœ‰้ซ˜ๆ€ง่ƒฝ,้ซ˜ๆ•ˆ็Ž‡,ๆ˜“ๆ‹“ๅฑ•็š„fastapi็ฎก็†ๅŽๅฐๆก†ๆžถ. ๅฏๅ‘่‡ชDjango-Admin,ๅนถไธ”ๆ‹ฅๆœ‰ไธ้€Š่‰ฒไบŽDjango-Admin็š„ๅผบๅคงๅŠŸ่ƒฝ. ๆบ็  ยท ๅœจ็บฟๆผ”็คบ ยท ๆ–‡ๆกฃ ยท ๆ–‡

AmisAdmin 318 Dec 31, 2022
๐Ÿšข Docker images and utilities to power your Python APIs and help you ship faster. With support for Uvicorn, Gunicorn, Starlette, and FastAPI.

๐Ÿšข inboard ๐Ÿณ Docker images and utilities to power your Python APIs and help you ship faster. Description This repository provides Docker images and a

Brendon Smith 112 Dec 30, 2022