Spaces:
Sleeping
Sleeping
from fastapi import FastAPI, Query, HTTPException | |
from typing import Dict, Optional | |
import requests | |
app = FastAPI() | |
def read_root(): | |
return {"message": "Hello, World!"} | |
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() | |