-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
60 lines (32 loc) · 1001 Bytes
/
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
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from database import engine
from routers import post, user, auth, vote
from config import settings
# models.Base.metadata.create_all(bind=engine)
app = FastAPI()
origins = ["*"]
app.add_middleware(
CORSMiddleware,
allow_origins= origins,
allow_credentials= True,
allow_methods=["*"],
allow_headers=["*"]
)
app.include_router(post.router)
app.include_router(user.router)
app.include_router(auth.router)
app.include_router(vote.router)
# using psycopg to connect to db
# import time
# import psycopg2
# from psycopg2.extras import RealDictCursor
# while True:
# try:
# conn = psycopg2.connect(host= 'localhost', database= 'fastapi', user= 'postgres', password= '26230', cursor_factory= RealDictCursor)
# cursor = conn.cursor()
# print('db connected')
# break
# except Exception as error:
# print(error)
# time.sleep(3)