mirror of
https://github.com/ttttupup/wxhelper.git
synced 2024-11-24 19:29:25 +08:00
test: add http server
This commit is contained in:
parent
bf0018ae05
commit
926babbc66
26
python/http_server.py
Normal file
26
python/http_server.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
from fastapi import FastAPI, Request
|
||||||
|
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
# pip install fastapi
|
||||||
|
# run command :uvicorn test:app --reload
|
||||||
|
# 127.0.0.1:8000/api
|
||||||
|
|
||||||
|
@app.post("/api")
|
||||||
|
def create_item(request: Request):
|
||||||
|
print("recv msg")
|
||||||
|
return {"code": 0, "msg": "success"}
|
||||||
|
|
||||||
|
|
||||||
|
@app.middleware("http")
|
||||||
|
async def TestCustomMiddleware(request: Request, call_next):
|
||||||
|
the_headers = request.headers
|
||||||
|
the_body = await request.json()
|
||||||
|
|
||||||
|
print(the_headers)
|
||||||
|
print(the_body)
|
||||||
|
|
||||||
|
response = await call_next(request)
|
||||||
|
|
||||||
|
return response
|
Loading…
Reference in New Issue
Block a user