stocks / app /main.py
vikaswalnutedu
feat: initial commit
b574d69
raw
history blame contribute delete
519 Bytes
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)