Fix formatting with black
This commit is contained in:
@ -8,24 +8,35 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
from app import ssl_heidi
|
||||
|
||||
|
||||
from app.routers import address, contact, proposal, dewar, shipment, puck, spreadsheet, logistics, auth, sample
|
||||
from app.routers import (
|
||||
address,
|
||||
contact,
|
||||
proposal,
|
||||
dewar,
|
||||
shipment,
|
||||
puck,
|
||||
spreadsheet,
|
||||
logistics,
|
||||
auth,
|
||||
sample,
|
||||
)
|
||||
from app.database import Base, engine, SessionLocal, load_sample_data
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# Determine environment and configuration file path
|
||||
environment = os.getenv('ENVIRONMENT', 'dev')
|
||||
config_file = Path(__file__).resolve().parent.parent / f'config_{environment}.json'
|
||||
environment = os.getenv("ENVIRONMENT", "dev")
|
||||
config_file = Path(__file__).resolve().parent.parent / f"config_{environment}.json"
|
||||
|
||||
# Load configuration
|
||||
with open(config_file) as f:
|
||||
config = json.load(f)
|
||||
|
||||
cert_path = config['ssl_cert_path']
|
||||
key_path = config['ssl_key_path']
|
||||
cert_path = config["ssl_cert_path"]
|
||||
key_path = config["ssl_key_path"]
|
||||
|
||||
# Generate SSL Key and Certificate if not exist (only for development)
|
||||
if environment == 'dev':
|
||||
if environment == "dev":
|
||||
Path("ssl").mkdir(parents=True, exist_ok=True)
|
||||
if not Path(cert_path).exists() or not Path(key_path).exists():
|
||||
ssl_heidi.generate_self_signed_cert(cert_path, key_path)
|
||||
@ -81,13 +92,13 @@ if __name__ == "__main__":
|
||||
import os
|
||||
|
||||
# Get environment from an environment variable
|
||||
environment = os.getenv('ENVIRONMENT', 'dev')
|
||||
environment = os.getenv("ENVIRONMENT", "dev")
|
||||
|
||||
# Paths for SSL certificates
|
||||
cert_path = "ssl/cert.pem"
|
||||
key_path = "ssl/key.pem"
|
||||
|
||||
if environment == 'test':
|
||||
if environment == "test":
|
||||
cert_path = "ssl/mx-aare-test.psi.ch.pem"
|
||||
key_path = "ssl/mx-aare-test.psi.ch.key"
|
||||
host = "0.0.0.0" # Bind to all interfaces
|
||||
@ -102,4 +113,4 @@ if __name__ == "__main__":
|
||||
log_level="debug",
|
||||
ssl_keyfile=key_path,
|
||||
ssl_certfile=cert_path,
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user