Page MenuHomePhabricator

Serving static file from Toolforge flask application
Open, Needs TriagePublic

Description

I am attempting to serve my banana da.json file from my Flask applications (currently experimenting with ordia).

I do get the correct URL from the browser request https://tools.wmflabs.org/ordia/i18n/da.json and this is also handled by my view.py. In the view function I am attempting to find the file on the file system with absdirname = join(dirname(__file__), 'i18n') however, Kubernetes/Toolforge does not get the full filename , but just ./ordia/app/i18n which seems to be insufficient for finding the file I the Flask application the returns 404 for that specific requests. The file da.json is present and available under /mnt/nfs/labstore-secondary-tools-project/ordia/www/python/ordia/ordia/app/i18n. How can I pass the correct directory name.

Event Timeline

Fnielsen created this task.Aug 16 2019, 7:58 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 16 2019, 7:58 AM
bd808 added a subscriber: bd808.Aug 16 2019, 9:06 AM

Maybe try using os.path.abspath() to resolve the path relative the the current working directory of the process?

bd808 assigned this task to Fnielsen.Aug 30 2019, 6:01 PM
bd808 added a project: Tools.