-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
50 lines (37 loc) · 917 Bytes
/
Copy pathmain.py
File metadata and controls
50 lines (37 loc) · 917 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
from typing import Union
from fastapi.middleware.cors import CORSMiddleware
from src.pydantic_model.pydantic_model import Create_Project
from src.services import crud
from fastapi import FastAPI,Depends
from sqlalchemy.orm import Session
import src.model.models as models
from database import SessionLocal, engine
from src.controller import controllers
models.Base.metadata.create_all(bind=engine)
app = FastAPI()
# app.include_routeer(file_upload.router)
origins = [
"http://localhost",
"http://localhost:8080",
"http://localhost:4000"
]
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Dependency
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
app.include_router(
controllers.router,
prefix="/v2/project",
tags=["projects"]
)