Spaces:
Sleeping
Sleeping
hashimotoa961 commited on
Commit ·
d0ee0d6
1
Parent(s): 5c199bb
fix for fastapi + uvicorn
Browse files
app.py
CHANGED
|
@@ -7,21 +7,23 @@ import logging
|
|
| 7 |
app = FastAPI()
|
| 8 |
logger = logging.getLogger(__name__)
|
| 9 |
|
| 10 |
-
@app.get("/")
|
| 11 |
-
def read_root():
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
-
@app.get("/api/")
|
|
|
|
| 17 |
def api(endpoint: str = Query(..., alias="endpoint"), other_params: Optional[Dict[str, str]] = None):
|
| 18 |
# クライアントからのリクエストデータを取得
|
|
|
|
|
|
|
| 19 |
if not endpoint:
|
| 20 |
raise HTTPException(status_code=400, detail="No endpoint specified")
|
| 21 |
|
| 22 |
# AWS API Gatewayにリクエストを転送
|
| 23 |
-
print(endpoint, other_params)
|
| 24 |
-
logger.info(f"{endpoint} {other_params}")
|
| 25 |
response = requests.get(endpoint, params=other_params)
|
| 26 |
|
| 27 |
# AWSからのレスポンスをクライアントに返す
|
|
|
|
| 7 |
app = FastAPI()
|
| 8 |
logger = logging.getLogger(__name__)
|
| 9 |
|
| 10 |
+
# @app.get("/")
|
| 11 |
+
# def read_root():
|
| 12 |
+
# print("Hello, World!")
|
| 13 |
+
# logger.info("Hello, World!")
|
| 14 |
+
# return {"message": "Hello, World!"}
|
| 15 |
+
|
| 16 |
|
| 17 |
+
# @app.get("/api/")
|
| 18 |
+
@app.get("/")
|
| 19 |
def api(endpoint: str = Query(..., alias="endpoint"), other_params: Optional[Dict[str, str]] = None):
|
| 20 |
# クライアントからのリクエストデータを取得
|
| 21 |
+
print(endpoint, other_params)
|
| 22 |
+
logger.info(f"{endpoint} {other_params}")
|
| 23 |
if not endpoint:
|
| 24 |
raise HTTPException(status_code=400, detail="No endpoint specified")
|
| 25 |
|
| 26 |
# AWS API Gatewayにリクエストを転送
|
|
|
|
|
|
|
| 27 |
response = requests.get(endpoint, params=other_params)
|
| 28 |
|
| 29 |
# AWSからのレスポンスをクライアントに返す
|