Apis tool base fastapi
Project description
配置文件示例
apis:
- name: "index"
path: "/index"
method: "Get"
handler: "apis.index"
- name: "save"
path: "/save"
method: "POST"
handler: "apis.save"
回调函数示例
from fastapi import Request
def index(request:Request):
print(request._query_params._dict)
return {"msg": "this is index msg"}
def save(data:dict):
return {"msg": "this is save msg", "data":data}
调用示例
from xapi.server import HTTPServer
server = HTTPServer()
server.start()
调用成功 日志
INFO:xapi.server:注册路由: /token POST -> apis.handler_token
INFO:xapi.server:注册路由: /p GET -> apis.p
INFO: Started server process [27480]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xfapi-0.0.8.tar.gz
(4.2 kB
view details)
File details
Details for the file xfapi-0.0.8.tar.gz.
File metadata
- Download URL: xfapi-0.0.8.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87adaadd5c0a375750e3110c8e55d5a36a1a9573e7326e615a9f8b090e5c1eb1
|
|
| MD5 |
dbfb2becfb858d272af2495b5eb5e678
|
|
| BLAKE2b-256 |
9b37a960214f6b439cdeedfe67a475c8f5ef7631368a1e79c546732fbcf38259
|