Spaces:
Sleeping
Sleeping
File size: 718 Bytes
ab54869 7f4c438 ab54869 7f4c438 ab54869 7f4c438 ab54869 7f4c438 ab54869 7f4c438 33e14f8 7f4c438 ab54869 7f4c438 ab54869 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from fastapi import FastAPI, Query, HTTPException
from typing import Dict, Optional
import requests
app = FastAPI()
@app.get("/")
def read_root():
return {"message": "Hello, World!"}
@app.get("/api/")
def api(endpoint: str = Query(..., alias="endpoint"), other_params: Optional[Dict[str, str]] = None):
# クライアントからのリクエストデータを取得
if not endpoint:
raise HTTPException(status_code=400, detail="No endpoint specified")
# AWS API Gatewayにリクエストを転送
print(endpoint, other_params)
response = requests.get(endpoint, params=other_params)
# AWSからのレスポンスをクライアントに返す
return response.json()
|