Update main.py
Browse files
main.py
CHANGED
@@ -2,7 +2,7 @@ from fastapi.responses import HTMLResponse
|
|
2 |
from fastapi.templating import Jinja2Templates
|
3 |
from fastapi import FastAPI, Request, HTTPException
|
4 |
from fastapi.middleware.cors import CORSMiddleware
|
5 |
-
from stdb import
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
@@ -17,6 +17,7 @@ app.add_middleware(
|
|
17 |
)
|
18 |
|
19 |
templates = Jinja2Templates(directory="templates")
|
|
|
20 |
|
21 |
@app.get("/", response_class=HTMLResponse)
|
22 |
async def read_root(request: Request):
|
@@ -35,7 +36,7 @@ async def read_root(request: Request):
|
|
35 |
@app.get('/data')
|
36 |
async def get_data(ticker: str, date: str, qty: int):
|
37 |
try:
|
38 |
-
response = get_equity_data(ticker, date, qty)
|
39 |
return response
|
40 |
except:
|
41 |
return {"Timeout" : "Error"}
|
@@ -43,7 +44,7 @@ async def get_data(ticker: str, date: str, qty: int):
|
|
43 |
@app.get('/stocks')
|
44 |
async def get_stocks_data():
|
45 |
try:
|
46 |
-
response = get_stocks_data()
|
47 |
return response
|
48 |
except:
|
49 |
return {"Timeout" : "Error"}
|
|
|
2 |
from fastapi.templating import Jinja2Templates
|
3 |
from fastapi import FastAPI, Request, HTTPException
|
4 |
from fastapi.middleware.cors import CORSMiddleware
|
5 |
+
from stdb import DataManager
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
|
|
17 |
)
|
18 |
|
19 |
templates = Jinja2Templates(directory="templates")
|
20 |
+
data_manager = DataManager()
|
21 |
|
22 |
@app.get("/", response_class=HTMLResponse)
|
23 |
async def read_root(request: Request):
|
|
|
36 |
@app.get('/data')
|
37 |
async def get_data(ticker: str, date: str, qty: int):
|
38 |
try:
|
39 |
+
response = data_manager.get_equity_data(ticker, date, qty)
|
40 |
return response
|
41 |
except:
|
42 |
return {"Timeout" : "Error"}
|
|
|
44 |
@app.get('/stocks')
|
45 |
async def get_stocks_data():
|
46 |
try:
|
47 |
+
response = data_manager.get_stocks_data()
|
48 |
return response
|
49 |
except:
|
50 |
return {"Timeout" : "Error"}
|