Update main.py
Browse files
main.py
CHANGED
@@ -3,15 +3,9 @@ from fastapi.templating import Jinja2Templates
|
|
3 |
from fastapi import FastAPI, Request, HTTPException
|
4 |
from fastapi.middleware.cors import CORSMiddleware
|
5 |
from utils import StockDataFetcher
|
6 |
-
from pydantic import BaseModel
|
7 |
-
from typing import List, Dict
|
8 |
-
|
9 |
|
10 |
app = FastAPI(swagger_ui_parameters={"syntaxHighlight.theme": "obsidian"})
|
11 |
|
12 |
-
class StockPriceResponse(BaseModel):
|
13 |
-
ltp: float
|
14 |
-
|
15 |
fetcher = StockDataFetcher()
|
16 |
|
17 |
origins = ["*"]
|
@@ -31,10 +25,7 @@ async def read_root(request: Request):
|
|
31 |
return templates.TemplateResponse("hello.html", {"request": request})
|
32 |
|
33 |
|
34 |
-
@app.get('/ltp'
|
35 |
-
summary="Get the latest price of a stock",
|
36 |
-
response_description="Latest stock price",
|
37 |
-
responses={200: {"content": {"application/json": {"example": {"ltp": 123.45}}}}})
|
38 |
async def get_data(ticker: str):
|
39 |
try:
|
40 |
response = fetcher.fetch_latest_price(ticker)
|
|
|
3 |
from fastapi import FastAPI, Request, HTTPException
|
4 |
from fastapi.middleware.cors import CORSMiddleware
|
5 |
from utils import StockDataFetcher
|
|
|
|
|
|
|
6 |
|
7 |
app = FastAPI(swagger_ui_parameters={"syntaxHighlight.theme": "obsidian"})
|
8 |
|
|
|
|
|
|
|
9 |
fetcher = StockDataFetcher()
|
10 |
|
11 |
origins = ["*"]
|
|
|
25 |
return templates.TemplateResponse("hello.html", {"request": request})
|
26 |
|
27 |
|
28 |
+
@app.get('/ltp')
|
|
|
|
|
|
|
29 |
async def get_data(ticker: str):
|
30 |
try:
|
31 |
response = fetcher.fetch_latest_price(ticker)
|