-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
57 lines (46 loc) · 1.63 KB
/
main.py
File metadata and controls
57 lines (46 loc) · 1.63 KB
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
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from src.routes.auth import router as auth_router
from src.routes.users import router as user_router
from src.routes.websocket import router as websocket_router
from src.routes.dev_routes import router as dev_router
app = FastAPI(
title="TrustMess API",
description="Real-time messaging API with WebSocket support",
version="1.2.0",
)
# ? CORS Middleware
app.add_middleware(
CORSMiddleware,
allow_origins=[
"http://localhost:5173",
"http://localhost:4173",
"http://127.0.0.1:5173",
"http://127.0.0.1:4173",
"http://192.168.1.43:5173",
"http://192.168.1.43:4173",
"http://192.168.1.110:5173",
"http://192.168.1.110:4173",
"https://trustmess.org",
],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# * Root route
# *****************************************************************************
@app.get("/")
async def read_root():
return {"status": "Ok", "docs": "/docs", "version": "1.2.0"}
# *****************************************************************************
# * Include routers
# *****************************************************************************
app.include_router(user_router)
app.include_router(auth_router)
app.include_router(websocket_router)
app.include_router(dev_router)
# *****************************************************************************
# ? Run the app with: uvicorn main:app --reload
if __name__ == "__main__":
import uvicorn
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)