All Projects → utmhikari → Start Fastapi

utmhikari / Start Fastapi

a lightweight web framework based on fastapi

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Start Fastapi

Webperl
Run Perl in the browser with WebPerl!
Stars: ✭ 221 (+360.42%)
Mutual labels:  web-application, web-application-framework, webapp
Node Red Contrib Uibuilder
Easily create data-driven web UI's for Node-RED using any (or no) front-end library. VueJS and bootstrap-vue included but change as desired.
Stars: ✭ 215 (+347.92%)
Mutual labels:  web-application, webapp
Appweb
Appweb Community Edition Embedded Web Server
Stars: ✭ 196 (+308.33%)
Mutual labels:  web-application, web-application-framework
Online-Food-Ordering-Web-App
Online Food Ordering System Website using basic PHP, SQL, HTML & CSS. You can use any one of XAMPP, WAMP or LAMP server to run the Web App
Stars: ✭ 96 (+100%)
Mutual labels:  web-application, webapp
Revel
A high productivity, full-stack web framework for the Go language.
Stars: ✭ 12,463 (+25864.58%)
Mutual labels:  web-application, web-application-framework
Sharry
Sharry is a self-hosted file sharing web application.
Stars: ✭ 170 (+254.17%)
Mutual labels:  web-application, webapp
System Design Primer
Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.
Stars: ✭ 154,659 (+322106.25%)
Mutual labels:  web-application, webapp
Musicode
🎶 Markup language for music creation and analysis! -- https://hlorenzi.github.io/musicode/
Stars: ✭ 34 (-29.17%)
Mutual labels:  web-application, webapp
hr-time
High Resolution Time
Stars: ✭ 43 (-10.42%)
Mutual labels:  web-application, webapp
performance-timeline
Performance Timeline
Stars: ✭ 102 (+112.5%)
Mutual labels:  web-application, webapp
Navigation Timing
Navigation Timing
Stars: ✭ 92 (+91.67%)
Mutual labels:  web-application, webapp
servant-beam-realworld-example-app
Exemplary fullstack Medium.com clone powered by Servant and Beam
Stars: ✭ 33 (-31.25%)
Mutual labels:  web-application, webapp
Awesome Django
Repository mirror of GitLab: https://gitlab.com/rosarior/awesome-django This repository is not monitored for issues, use original at GitLab.
Stars: ✭ 8,527 (+17664.58%)
Mutual labels:  web-application, web-application-framework
Alumna
[Alpha release of v3] Development platform for humans / Plataforma de desenvolvimento para humanos
Stars: ✭ 32 (-33.33%)
Mutual labels:  web-application, webapp
Theorytracker
🎼 HTML5/WebAudio multi-track functional harmony analysis and songwriting app! -- https://hlorenzi.github.io/theorytracker/
Stars: ✭ 62 (+29.17%)
Mutual labels:  web-application, webapp
workflowmanager-viewer-js
Source code for ArcGIS Workflow Manager JavaScript viewer - Manage your workflows on the web.
Stars: ✭ 23 (-52.08%)
Mutual labels:  web-application, webapp
SyncPaint
A web app for synchronized group drawing. Draw together with other people in real time.
Stars: ✭ 42 (-12.5%)
Mutual labels:  web-application, webapp
Php Security Check List
PHP Security Check List [ EN ] 🌋 ☣️
Stars: ✭ 262 (+445.83%)
Mutual labels:  web-application, web-application-framework
Botvid 19
Messenger Bot that scrapes for COVID-19 data and periodically updates subscribers via Facebook Messages. Created using Python/Flask, MYSQL, HTML, Heroku
Stars: ✭ 34 (-29.17%)
Mutual labels:  webapp
Seven23
Fully manual budget app to track personal expenses. 100% opensource, with privacy by design.
Stars: ✭ 36 (-25%)
Mutual labels:  webapp

start-fastapi

Version 2021, based on FastAPI, an easy-to-use web app developed upon Starlette Framework

Requirements

  • python 3.6+ (for static typing check)
  • pip3 install -r ./requirements.txt
  • idea/pycharm (recommended) + venv

Structure

The web application is based on onion style~

onion

The directory structure is:

  • app: logics for your application, includes __init__.py as entry of user modules
    • handler: controllers
    • middleware: router middleware, like cors
    • model: basic data models and internal logics
    • service: external logics (to users)
  • cfg: config of different envs
  • core: low level libraries and logics, includes __init__.py as entry of core modules, better make it able to be reused in other projects
    • handler
    • lib: shortcut apis for user to build logics
    • model
    • service
      • trans: transaction service, for managing tasks running in background
  • misc: misc parts, like build, test scripts, etc
    • build: build scripts
    • dev: resources for dev usage
      • gen_code.py: a script for generating codes
    • doc: docs
    • test: test scripts
  • main.py: main entry, init uvicorn and start fastapi app
  • requirements.txt: py package requirements

Quick Start

Launch App Server

Run ./main.py to start the example, which includes:

  • core modules: health check handler, basic models, transaction service
  • cors middleware configured with wildcard *
  • test handlers, models and service: simulates a simple market trade system with products and customers
    • examples of websocket and upload file are also included in test handlers

The internal steps are:

  • ./main.py loads the configs inside ./cfg/{env} on cmd args, then calls uvicorn.run to start fastapi app at ./app/__init__.py
  • in ./app/__init__.py, core modules and user handlers/models/services are loaded at startup event of fastapi app

You can put your launch scripts inside ./misc/build for your different launch options

Coding Guide

To build your logic, common steps are follows:

  • ./main.py runs server in dev environment in default, in which hot-reload is enabled
  • add handlers in ./app/handler, add corresponding import & APP.include_router codes in ./app/__init__.py
  • add data models in ./app/model, add services in ./app/service
  • add middlewares in ./app/middleware if necessary

Some tips for coding:

  • GET /docs to test the routers on web page
  • Avoid using coroutines (async def functions), as it may block the main evtloop, so that other requests are not handled in time. def functions will be invoked in different threads
  • codes of ./core should be shareable (for other projects), codes of ./app should fit with current project
  • You can use ./misc/dev/gen_code.py to generate template codes for handlers, models & services. Exec it with working directory as project root directory
  • Code models based on pydantic.BaseModel, it's powerful

HTTP Response

Most of the handled requests should contain a status code of 200

A simple solution is to use Resp model in ./core/model/handler.py to generate response body for your handlers

{
  "success": bool,
  "message": str,
  "code": IntEnum,
  "data": Any,
}

Use Resp.ok to generate success response and use Resp.err to generate error response

Misc

WebSocket

The test handler ./app/handler/test.py contains ws handler examples

To know more about it, see websocket documentation

Deployment

Run ./misc/build/pack.sh to pack the project into ./misc/build/start-fastapi.tar.gz

See ./misc/build/Dockerfile for an example of docker deployment

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].