2024-03-28 21:23:25 +01:00
|
|
|
from fastapi import FastAPI
|
|
|
|
from starlette.middleware.authentication import AuthenticationMiddleware
|
|
|
|
import uvicorn
|
|
|
|
|
2024-04-13 22:43:03 +02:00
|
|
|
from app.database import engine, Base
|
|
|
|
from app.models import *
|
|
|
|
|
2024-04-14 01:42:51 +02:00
|
|
|
from app.routers import chargepoint_v1, user_v1, ocpp_v1
|
2024-04-13 22:43:03 +02:00
|
|
|
from app.util.websocket_auth_backend import BasicAuthBackend
|
2024-03-28 21:23:25 +01:00
|
|
|
|
|
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
|
|
|
|
def create_ocpp_app():
|
|
|
|
app_ocpp = FastAPI(
|
|
|
|
responses={404: {"description": "Not found"}},
|
|
|
|
)
|
|
|
|
app_ocpp.include_router(ocpp_v1.router)
|
|
|
|
app_ocpp.add_middleware(AuthenticationMiddleware, backend=BasicAuthBackend())
|
|
|
|
|
|
|
|
return app_ocpp
|
|
|
|
|
|
|
|
def create_app():
|
|
|
|
app = FastAPI(
|
|
|
|
responses={404: {"description": "Not found"}},
|
|
|
|
)
|
|
|
|
|
|
|
|
app.include_router(chargepoint_v1.router, prefix="/v1")
|
2024-04-14 01:42:51 +02:00
|
|
|
app.include_router(user_v1.router, prefix="/v1")
|
2024-03-28 21:23:25 +01:00
|
|
|
app.mount(path="/v1/ocpp", app=create_ocpp_app())
|
|
|
|
|
|
|
|
return app
|
|
|
|
|
|
|
|
app = create_app()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8000, log_level="info")
|