Apis tool base fastapi
Project description
配置文件示例
apis:
- name: "token"
path: "/token"
method: "POST"
handler: "apis.handler_token"
- name: "p"
path: "/p"
method: "GET"
handler: "apis.p"
回调函数示例
from fastapi import Request
def handler_token(data:dict):
print(data)
return {"token": "your_token_here"}
def p(request:Request):
print(request._query_params._dict)
return {"data": "your_token_here"}
调用示例
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.7.tar.gz
(4.1 kB
view details)
File details
Details for the file xfapi-0.0.7.tar.gz.
File metadata
- Download URL: xfapi-0.0.7.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dee5f4d85f22a63f3524454106e749c8c1fc8bd5861c0d2c2a96a0b2740817e1
|
|
| MD5 |
b490359daf91d1462e01c38302ce2167
|
|
| BLAKE2b-256 |
7c5a6d1056e9573677d52463ffcf9aba206055d7f9a092281e6574e70332c7da
|