Giter VIP home page Giter VIP logo

fastproject's Introduction


Chinese Documentation: https://www.cnblogs.com/mazhiyong/

Source Code: https://github.com/zhiyongma/fastproject


Requirements

Python 3.6+

You should install the requirments below first.

$ pip install fastapi
$ pip install pymysql
$ pip install sqlalchemy
$ pip install pyjwt
$ pip install bcrypt
$ pip install passlib
$ pip install python-multipart

Then you should create your mysql database. Sample sql in the deploy directory.
You can configure the database connection in config.py.

You will also need an ASGI server, for production such as Uvicorn or Hypercorn.

$ pip install uvicorn

For production deployment, you should also install Gunicorn.

$ pip install gunicorn

Example

Local Run

$ uvicorn local:app --reload

Server Run

Run the server with gunicorn.

$ gunicorn  -c  /data/fastest/gunicorn.py -e FASTAPI_ENV=production  run:app
  • -c: gunicorn config.
  • -e: environment parameter.

Run the server with service.
See the file gunicorn_fast.service in deploy directory. You should put it in /usr/lib/systemd/system for linux os.

$ systemctl start/stop/restart/enable gunicorn_fast.service

Production config

  • -e: FASTAPI_ENV=production.
  • mysql: configure file config.py .
  • gunicorn: configure file gunicorn.py .
  • service: configure file gunicorn_fast.service .

remarks: the pidfile in gunicorn_fast.service and gunicorn.py should point to the same one file.

API test

1、user register

FastAPI

2、user login

FastAPI

3、user info

FastAPI

License

This project is licensed under the terms of the MIT license.

fastproject's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.