Coder Social home page Coder Social logo

ygbingo / fastapi_example Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 214 KB

Python 312 use fastapi + sqlalchemy + asyncio build a backend framework <br> 100行代码实现基于 fastapi + sqlalchemy + asyncio 实现一个AI后端服务

Python 98.45% Dockerfile 1.55%
fastapi python sqlalchemy

fastapi_example's Introduction

fastapi_ML

基于 fastapi + sqlalchemy + asyncio 实现一个AI后端服务 功能包括:

  • fastapi + pydantic 进行服务端的body映射
  • sqlalchemy + asyncio 数据库异步服务
  • docker 部署与打包

目录

  • main.py: 入口
  • config.py: 配置信息
  • models: 数据结构
  • core: 核心代码, 如数据处理、算法类
  • routers: api接口
  • utils: 工具类, 日志等

运行

  1. clone代码
  2. 安装环境
  3. 运行fastapi
uvicorn app.main:app --reload

测试

  1. 创建数据:
python scripts/mock_postgres.py
  1. 发送请求:
curl --location 'http://127.0.0.1:8000/ml/clustering/0c46960f-f826-4cf8-b4a6-e58af47d631c' --header 'Content-Type: application/json' --data '{"creator": "34eb5596-57b7-4056-a5cd-24eba780132a","options": {"method": "DBSCAN","basis": 0,"eps": "3","min_samples": "20"}}'

request

  1. 接收请求 response

使用docker部署

  1. clone代码
  2. build docker
docker build . -t app:<TAG>
  1. modify docker-compose:
  2. modify example.env
  3. copy example.env to .env
  4. docker-compose up -d app --env-file .env

fastapi_example's People

Contributors

ygbingo avatar imgbotapp avatar

Watchers

 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.