-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
51 lines (42 loc) · 1.18 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
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from prometheus_fastapi_instrumentator import Instrumentator
from routers import imports
import db
DESCRIPTION = """
A lightweight python api to import data PostGIS from a multitude of locations.
"""
app = FastAPI(
title="FastVector",
description=DESCRIPTION,
version="0.0.1",
contact={
"name": "Michael Keller",
"email": "michaelkeller03@gmail.com",
},
license_info={
"name": "The MIT License (MIT)",
"url": "https://mit-license.org/",
},
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(
imports.router,
prefix="/api/v1/import",
tags=["import"],
)
@app.on_event("startup")
async def startup_event():
"""Application startup: register the database connection and create table list."""
await db.connect_to_db(app)
@app.on_event("shutdown")
async def shutdown_event():
"""Application shutdown: de-register the database connection."""
await db.close_db_connection(app)
Instrumentator().instrument(app).expose(app)