From 926babbc668ad783853176d8bf0f9714a7d82e29 Mon Sep 17 00:00:00 2001 From: hugy <504650082@qq.com> Date: Mon, 5 Jun 2023 14:19:12 +0800 Subject: [PATCH] test: add http server --- python/http_server.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 python/http_server.py diff --git a/python/http_server.py b/python/http_server.py new file mode 100644 index 0000000..98c154c --- /dev/null +++ b/python/http_server.py @@ -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 \ No newline at end of file