https and ssl integration on the backend, frontend and started integration of logistics app as a separate frontend
This commit is contained in:
@ -2,12 +2,20 @@
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from app import ssl_heidi
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
from app.routers import address, contact, proposal, dewar, shipment, puck, spreadsheet, logistics
|
||||
from app.database import Base, engine, SessionLocal, load_sample_data
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# Generate SSL Key and Certificate if not exist
|
||||
Path("ssl").mkdir(parents=True, exist_ok=True)
|
||||
if not Path("ssl/cert.pem").exists() or not Path("ssl/key.pem").exists():
|
||||
ssl_heidi.generate_self_signed_cert("ssl/cert.pem", "ssl/key.pem")
|
||||
|
||||
# Apply CORS middleware
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
@ -39,9 +47,11 @@ app.include_router(dewar.router, prefix="/dewars", tags=["dewars"])
|
||||
app.include_router(shipment.router, prefix="/shipments", tags=["shipments"])
|
||||
app.include_router(puck.router, prefix="/pucks", tags=["pucks"])
|
||||
app.include_router(spreadsheet.router, tags=["spreadsheet"])
|
||||
app.include_router(dewar.router, prefix="/logistics", tags=["logistics"])
|
||||
app.include_router(logistics.router, prefix="/logistics", tags=["logistics"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
|
||||
ssl_context.load_cert_chain(certfile="ssl/cert.pem", keyfile="ssl/key.pem")
|
||||
|
||||
uvicorn.run(app, host="127.0.0.1", port=8000, log_level="debug")
|
||||
uvicorn.run(app, host="127.0.0.1", port=8000, log_level="debug", ssl_context=ssl_context)
|
||||
|
Reference in New Issue
Block a user