Spaces:
Runtime error
Runtime error
File size: 519 Bytes
b574d69 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from .stocks import get_stock_data
app = FastAPI()
@app.get("/")
def health_check():
return {"health_check": "OK"}
@app.post("/stock")
def get_stock(ticker, start=None, end=None):
try:
df = get_stock_data(ticker, start, end)
return JSONResponse(content=df.to_json(orient="records"), media_type="application/json")
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
|