Shriraj Kulkarni commited on
Commit
c900d71
·
1 Parent(s): c4464e4

Add application file_5

Browse files
Files changed (1) hide show
  1. main.py +18 -0
main.py CHANGED
@@ -1,14 +1,32 @@
1
  from fastapi import FastAPI, Response, status, File, Form, UploadFile
2
  from pydantic import BaseModel
3
  import joblib
 
4
 
5
  class Airflow(BaseModel):
6
  topic: str
7
 
8
  app = FastAPI()
9
 
 
 
 
 
 
 
 
 
 
 
 
10
  model = joblib.load("gradient_boosting.joblib")
11
 
 
 
 
 
 
 
12
  @app.post("/api/volume_prediction")
13
  async def predict_volume(vol_moving_avg: float = Form(), adj_close_rolling_med: float = Form()):
14
  features = [vol_moving_avg, adj_close_rolling_med]
 
1
  from fastapi import FastAPI, Response, status, File, Form, UploadFile
2
  from pydantic import BaseModel
3
  import joblib
4
+ from fastapi.middleware.cors import CORSMiddleware
5
 
6
  class Airflow(BaseModel):
7
  topic: str
8
 
9
  app = FastAPI()
10
 
11
+
12
+ origins = [ "https://huggingface.co", "https://*.huggingface.co",]
13
+
14
+ app.add_middleware(
15
+ CORSMiddleware,
16
+ allow_origins=origins,
17
+ allow_credentials=True,
18
+ allow_methods=["*"],
19
+ allow_headers=["*"],
20
+ )
21
+
22
  model = joblib.load("gradient_boosting.joblib")
23
 
24
+
25
+ @app.post("/")
26
+ def read_root():
27
+ return {"Hello": "World!"}
28
+
29
+
30
  @app.post("/api/volume_prediction")
31
  async def predict_volume(vol_moving_avg: float = Form(), adj_close_rolling_med: float = Form()):
32
  features = [vol_moving_avg, adj_close_rolling_med]