From 0550d12106548f23a9182df878d155905f9f40dc Mon Sep 17 00:00:00 2001 From: Craig Quiter Date: Sun, 18 Aug 2024 15:04:01 -0700 Subject: [PATCH] Black format --- backend/config.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/config.py b/backend/config.py index 46e9b1a73..d40487699 100644 --- a/backend/config.py +++ b/backend/config.py @@ -842,6 +842,7 @@ ENABLE_COMMUNITY_SHARING = PersistentConfig( os.environ.get("ENABLE_COMMUNITY_SHARING", "True").lower() == "true", ) + def validate_cors_origins(origins): for origin in origins: if origin != "*": @@ -853,7 +854,9 @@ def validate_cors_origin(origin): # Check if the scheme is either http or https if parsed_url.scheme not in ["http", "https"]: - raise ValueError(f"Invalid scheme in CORS_ALLOW_ORIGIN: '{origin}'. Only 'http' and 'https' are allowed.") + raise ValueError( + f"Invalid scheme in CORS_ALLOW_ORIGIN: '{origin}'. Only 'http' and 'https' are allowed." + ) # Ensure that the netloc (domain + port) is present, indicating it's a valid URL if not parsed_url.netloc: @@ -868,10 +871,13 @@ def validate_cors_origin(origin): CORS_ALLOW_ORIGIN = os.environ.get("CORS_ALLOW_ORIGIN", "*").split(";") if "*" in CORS_ALLOW_ORIGIN: - log.warning("\n\nWARNING: CORS_ALLOW_ORIGIN IS SET TO '*' - NOT RECOMMENDED FOR PRODUCTION DEPLOYMENTS.\n") + log.warning( + "\n\nWARNING: CORS_ALLOW_ORIGIN IS SET TO '*' - NOT RECOMMENDED FOR PRODUCTION DEPLOYMENTS.\n" + ) validate_cors_origins(CORS_ALLOW_ORIGIN) + class BannerModel(BaseModel): id: str type: str