-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
40 lines (30 loc) · 845 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
from fastapi import FastAPI
import uvicorn
from db import models
from db.database import engine
from routers import posts, users, comment
from fastapi.staticfiles import StaticFiles
from auth import authentication
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
models.Base.metadata.create_all(engine)
app.include_router(authentication.router)
app.include_router(users.router)
app.include_router(posts.router)
app.include_router(comment.router)
@app.get("/")
def root():
return "Initial commit!"
origins = [
'*'
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=['*'],
allow_headers=["*"]
)
app.mount('/images', StaticFiles(directory='images'), name='images')
if __name__ == '__main__':
uvicorn.run('main:app', port=8000, reload=True)