This is an automated email from the ASF dual-hosted git repository.
gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
The following commit(s) were added to refs/heads/trunk by this push:
new 9fe9107 Fix operation for running in different contexts.
9fe9107 is described below
commit 9fe91077c1a363eb44f9efaef952156e4f9e098b
Author: Greg Stein <[email protected]>
AuthorDate: Mon Oct 27 16:06:19 2025 -0500
Fix operation for running in different contexts.
* construct the app with the correct APP_DIR value (rather than $cwd).
Disable Quart's builtin static file handling, as it interfered with
our own handling.
* clean up the static handling: global STATICDIR and explicitly allow
just APP.get() routing.
---
v3/server/main.py | 2 +-
v3/server/pages.py | 9 +++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/v3/server/main.py b/v3/server/main.py
index 7659d6c..dd482c8 100755
--- a/v3/server/main.py
+++ b/v3/server/main.py
@@ -48,7 +48,7 @@ def main():
asfquart.generics.OAUTH_URL_INIT =
"https://oauth.apache.org/auth?state=%s&redirect_uri=%s"
asfquart.generics.OAUTH_URL_CALLBACK =
"https://oauth.apache.org/token?code=%s"
- app = asfquart.construct('steve')
+ app = asfquart.construct('steve', app_dir=THIS_DIR, static_folder=None)
# Now that we have an APP, import modules that will add page
# and API endpoints into the APP.
diff --git a/v3/server/pages.py b/v3/server/pages.py
index 70d48d3..d90a5c1 100644
--- a/v3/server/pages.py
+++ b/v3/server/pages.py
@@ -41,6 +41,7 @@ _LOGGER = logging.getLogger(__name__)
THIS_DIR = pathlib.Path(__file__).resolve().parent
DB_FNAME = THIS_DIR / APP.cfg.db
TEMPLATES = THIS_DIR / 'templates'
+STATICDIR = THIS_DIR / 'static'
sys.path.insert(0, str(THIS_DIR.parent))
import steve.election
@@ -425,12 +426,12 @@ async def about_page():
# Route to serve static files (CSS and JS)
[email protected]('/static/<path:filename>')
[email protected]('/static/<path:filename>')
async def serve_static(filename):
- return await quart.send_from_directory(THIS_DIR / 'static', filename)
[email protected]('/favicon.ico')
+ return await quart.send_from_directory(STATICDIR, filename)
[email protected]('/favicon.ico')
async def serve_favicon():
- return await quart.send_from_directory(THIS_DIR / 'static', 'favicon.ico')
+ return await quart.send_from_directory(STATICDIR, 'favicon.ico')
def format_datetime(dt):