enh(): Adds configurable CORS

* Adds CORS configuration in the config file
* Enables CORS to be toggled through config
This commit is contained in:
Elia el Lazkani 2024-12-24 01:29:35 +01:00 committed by Elia El Lazkani
parent c036d042c3
commit 35c8dfd21a
2 changed files with 4 additions and 1 deletions

View file

@ -1,6 +1,7 @@
Server:
host: 127.0.0.1
port: 8000
cors: False
Web:
host: 127.0.0.1

View file

@ -23,7 +23,9 @@ class Web:
def init(self):
self.app = Flask(__name__)
self.setup_routes()
CORS(self.app)
if server_config and server_config.get("cors", False):
self.logger.debug("Enabling CORS...")
CORS(self.app)
def setup_routes(self):
self.app.add_url_rule("/", "/", self.handler.index, methods=["GET"])