Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,20 +1,22 @@
|
|
| 1 |
# main.py
|
| 2 |
from fastapi import FastAPI, Request, UploadFile
|
| 3 |
from typing import Any, Dict
|
|
|
|
| 4 |
|
| 5 |
app = FastAPI()
|
| 6 |
|
| 7 |
@app.post("/echo")
|
| 8 |
async def echo(request: Request) -> Dict[str, Any]:
|
| 9 |
body_bytes = await request.body()
|
|
|
|
| 10 |
|
| 11 |
-
print("\n" + "="*30 + " π NEW REQUEST " + "="*30)
|
| 12 |
# print("πΉ Method:", request.method)
|
| 13 |
# print("π URL:", str(request.url))
|
| 14 |
# print("π Headers:", dict(request.headers))
|
| 15 |
# print("\nπ¦ Raw body (bytes):")
|
| 16 |
# print(body_bytes)
|
| 17 |
-
print("
|
| 18 |
print(body_bytes.decode("utf-8", errors="ignore"))
|
| 19 |
print("="*75)
|
| 20 |
|
|
|
|
| 1 |
# main.py
|
| 2 |
from fastapi import FastAPI, Request, UploadFile
|
| 3 |
from typing import Any, Dict
|
| 4 |
+
from datetime import datetime
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
| 8 |
@app.post("/echo")
|
| 9 |
async def echo(request: Request) -> Dict[str, Any]:
|
| 10 |
body_bytes = await request.body()
|
| 11 |
+
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 12 |
|
| 13 |
+
print("\n" + "="*30 + f" π NEW REQUEST ({now}) " + "="*30)
|
| 14 |
# print("πΉ Method:", request.method)
|
| 15 |
# print("π URL:", str(request.url))
|
| 16 |
# print("π Headers:", dict(request.headers))
|
| 17 |
# print("\nπ¦ Raw body (bytes):")
|
| 18 |
# print(body_bytes)
|
| 19 |
+
print("π Request body:")
|
| 20 |
print(body_bytes.decode("utf-8", errors="ignore"))
|
| 21 |
print("="*75)
|
| 22 |
|