52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
import locale
|
|
import os
|
|
|
|
import sentry_sdk
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from fabcal.routers import api_v1, frontend
|
|
|
|
|
|
sentry_sdk.init(
|
|
dsn=os.environ.get("SENTRY_DSN"),
|
|
# Add data like request headers and IP for users, if applicable;
|
|
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
|
|
send_default_pii=True,
|
|
# Set traces_sample_rate to 1.0 to capture 100%
|
|
# of transactions for tracing.
|
|
traces_sample_rate=1.0,
|
|
# Set profiles_sample_rate to 1.0 to profile 100%
|
|
# of sampled transactions.
|
|
# We recommend adjusting this value in production.
|
|
profiles_sample_rate=1.0,
|
|
)
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
|
|
for framework in ["normalize.css", "milligram", "@fortawesome/fontawesome-free"]:
|
|
app.mount(f"/assets/{framework}", StaticFiles(directory=f"node_modules/{framework}"), name=framework)
|
|
|
|
app.include_router(api_v1.router, prefix="/api/v1")
|
|
app.include_router(frontend.router, prefix="")
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=[
|
|
"https://fablab-altmuehlfranken.de",
|
|
"https://www.fablab-altmuehlfranken.de",
|
|
],
|
|
)
|
|
|
|
|
|
locale.setlocale(locale.LC_TIME, locale.getlocale())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(app, debug=True)
|