Skip to main content

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


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.3.tar.gz (1.9 kB view details)

Uploaded Source

File details

Details for the file xfapi-0.0.3.tar.gz.

File metadata

  • Download URL: xfapi-0.0.3.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for xfapi-0.0.3.tar.gz
Algorithm Hash digest
SHA256 59eff2ca78de5c8f09da8421277587aa0e007a9e91f3200b172bdb6759d2a88e
MD5 1fe07926427abb86096c733cdd3406b2
BLAKE2b-256 7678e22e1aac3f37425b7d31e10f7c1c3056a329c68b0b91361399c5f4f7fe50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page