feat(#20): Adds Enable UI feature to disable serving the UI #21

Merged
elia merged 1 commit from enable-ui into main 2024-12-25 21:01:22 +00:00
3 changed files with 13 additions and 11 deletions

View file

@ -3,6 +3,7 @@ Server:
port: 8000
scheme: http
cors: False
enable_ui: True
static_folder: ui/
Database:

2
poetry.lock generated
View file

@ -1136,4 +1136,4 @@ watchdog = ["watchdog (>=2.3)"]
[metadata]
lock-version = "2.0"
python-versions = "^3.10"
content-hash = "cdbbaa8d1f22a904c7cc3fa51f5fbaf5f19a99f2f5fd9715adfe7abf766b05f0"
content-hash = "64cb750d8d7e5ad3e10d7f53f311971c09849247b0ea3d82a66a7f368837f63f"

View file

@ -31,16 +31,17 @@ class Web:
CORS(self.app)
def setup_routes(self):
self.app.add_url_rule(
"/", "/", self.handler.index, methods=["GET"], defaults={"path": ""}
)
self.app.add_url_rule("/<path:path>", "/", self.handler.index, methods=["GET"])
self.app.add_url_rule(
"/static/css/<path:path>", "css", self.handler.css, methods=["GET"]
)
self.app.add_url_rule(
"/static/js/<path:path>", "js", self.handler.js, methods=["GET"]
)
if self.handler.configuration.get("Server", None)["enable_ui"]:
self.app.add_url_rule(
"/", "/", self.handler.index, methods=["GET"], defaults={"path": ""}
)
self.app.add_url_rule("/<path:path>", "/", self.handler.index, methods=["GET"])
self.app.add_url_rule(
"/static/css/<path:path>", "css", self.handler.css, methods=["GET"]
)
self.app.add_url_rule(
"/static/js/<path:path>", "js", self.handler.js, methods=["GET"]
)
self.app.add_url_rule(
"/api/v1/shorten", "shorten", self.handler.shortenit, methods=["POST"]
)