File size: 757 Bytes
0a7b47e
 
 
 
89eb9ba
0a7b47e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d7df8d0
0a7b47e
 
 
89eb9ba
0a7b47e
89eb9ba
 
 
 
 
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
from restful.routes import route
from fastapi.responses import RedirectResponse
from fastapi.middleware.cors import CORSMiddleware
from restful.cachings import close_caching_connector

app = FastAPI(
    title = "Cryptocurency Prediction Service",
    version = "1.0"
)

# CORS Middleware
app.add_middleware(
    CORSMiddleware,
    allow_origins = ["*"],
    allow_methods = ["*"],
    allow_headers = ["*"],
    allow_credentials = True,
)

app.include_router(
    router = route,
    prefix = '/crypto',
    tags = ['Cryptocurrency']
)

@app.get("/", tags = ['Main'])
def root() -> None:
    return RedirectResponse(url="/docs")


@app.on_event("shutdown")
async def on_shutdown() -> None:
    await close_caching_connector()