Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,6 @@
|
|
1 |
from fastapi import FastAPI, Request
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
3 |
-
import uvicorn
|
4 |
import logging
|
5 |
-
import requests
|
6 |
import json
|
7 |
|
8 |
# Configure logging
|
@@ -49,20 +47,6 @@ async def logging_proxy(request: Request, full_path: str):
|
|
49 |
|
50 |
logger.info(f"Incoming request: {json.dumps(log_data, indent=2)}")
|
51 |
|
52 |
-
# Forward the request (replace with your desired forwarding logic)
|
53 |
-
# In this example, we just log the request and return a simple response.
|
54 |
-
# You can modify this part to forward to a specific URL or service.
|
55 |
-
# Example (modify as needed):
|
56 |
-
# target_url = f"https://some-backend-service.com/{full_path}"
|
57 |
-
# response = requests.request(
|
58 |
-
# method=request.method,
|
59 |
-
# url=target_url,
|
60 |
-
# headers=dict(request.headers),
|
61 |
-
# params=dict(request.query_params),
|
62 |
-
# data=body
|
63 |
-
# )
|
64 |
-
# return Response(content=response.content, status_code=response.status_code)
|
65 |
-
|
66 |
return {
|
67 |
"message": "Request logged successfully",
|
68 |
"logged_data": log_data
|
@@ -72,5 +56,4 @@ async def logging_proxy(request: Request, full_path: str):
|
|
72 |
logger.error(f"Error processing request: {e}")
|
73 |
return {"error": "An error occurred while processing the request"}
|
74 |
|
75 |
-
|
76 |
-
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
1 |
from fastapi import FastAPI, Request
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
3 |
import logging
|
|
|
4 |
import json
|
5 |
|
6 |
# Configure logging
|
|
|
47 |
|
48 |
logger.info(f"Incoming request: {json.dumps(log_data, indent=2)}")
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
return {
|
51 |
"message": "Request logged successfully",
|
52 |
"logged_data": log_data
|
|
|
56 |
logger.error(f"Error processing request: {e}")
|
57 |
return {"error": "An error occurred while processing the request"}
|
58 |
|
59 |
+
Find More
|
|