Spaces:
Runtime error
Runtime error
| from fastapi import FastAPI | |
| from fastapi.responses import JSONResponse | |
| from .stocks import get_stock_data | |
| app = FastAPI() | |
| def health_check(): | |
| return {"health_check": "OK"} | |
| 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) | |