-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
66 lines (53 loc) · 1.45 KB
/
main.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from fastapi import FastAPI
# from fastapi.middleware.cors import CORSMiddleware
from starlette.middleware.cors import CORSMiddleware
from starlette.middleware import Middleware
from api.routers import augment, signal, auth
from api.db import connect_to_mongo, close_mongo_connection
tags_metadata = [
{
"name": "signal",
"description": (
"Signal can be an audio file. "
"On posting, background process will "
"initiate signal separation. "
"Depending upon the signal type different "
"separator can be used."
),
}
]
origins = [
# "http://localhost:3000",
"*"
]
api = FastAPI(
openapi_tags=tags_metadata,
title="Signal Separation API",
middleware=[
Middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
],
)
# api.add_middleware(
# CORSMiddleware,
# allow_origins=origins,
# allow_credentials=True,
# allow_methods=["*"],
# allow_headers=["*"],
# )
api.add_event_handler("startup", connect_to_mongo)
api.add_event_handler("shutdown", close_mongo_connection)
api.include_router(augment)
api.include_router(auth)
api.include_router(signal)
@api.get("/")
async def root():
return {"message": "Hello Bigger Applications!"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(api)