Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (38 loc) · 1.28 KB
/
Copy pathmain.py
File metadata and controls
47 lines (38 loc) · 1.28 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
"""
context0_app.py
---
"""
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware
from app.api.router import router as api_router
from app.core.logging import setup_logging
from app.settings import settings
from app.warning import print_boxed_auth_warning
# https://www.reddit.com/r/Python/comments/1dkrfgh/open_source_python_projects_with_good_software/
# https://github.com/blakeblackshear/frigate/blob/dev/frigate/config/auth.py
# https://github.com/polarsource/polar/blob/main/server/polar/api.py
# https://github.com/neuml/txtai/blob/master/src/python/txtai/app/base.py
# https://github.com/praw-dev/praw/blob/main/praw/config.py
# https://github.com/pallets/flask/blob/main/src/flask/ctx.py
#Set up Logging
setup_logging()
if settings.auth_disabled:
print_boxed_auth_warning()
app = FastAPI()
# Enable CORS
app.add_middleware(
CORSMiddleware,
allow_origins=settings.cors_origins,
# TODO: Replace "*" with your frontend domain like
# ["http://localhost:3000", "https://yourfrontend.com"]
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
import logging
# add API router
app.include_router(api_router)
# Add Middleware
#app.add_middleware(AuthLoggingMiddleware)
# Register error handlers
#register_error_handlers(app)