-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (23 loc) · 691 Bytes
/
main.py
File metadata and controls
37 lines (23 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from fastapi import FastAPI, BackgroundTasks, HTTPException
from pydantic import BaseModel
from extract import *
import os
SECRET = os.getenv("SECRET")
#
app = FastAPI()
class Msg(BaseModel):
msg: str
secret: str
@app.get("/")
async def root():
return {"message": "Hello World. Welcome to FastAPI!"}
@app.get("/homepage")
async def demo_get():
driver=createDriver()
homepage = getGoogleHomepage(driver)
driver.close()
return homepage
@app.post("/backgroundDemo")
async def demo_post(inp: Msg, background_tasks: BackgroundTasks):
background_tasks.add_task(doBackgroundTask, inp)
return {"message": "Success, background task started"}