i'm using send_from_directory in flask serve static js assets. app structure looks this:
/basefolder /app __init__.py /js/ jquery.js run.py /js/ jquery.js the __init__.py responsible of app management , has following:
app = flask(__name__) [...] @app.route('/js/<path:path>') def send_js(path): return send_from_directory('js',path) [...] def go(): [...] app.run() the app kicks off run.py file runs go function in file above. (this mirrors app setup of app in flask web development should typical use case flask.)
theoretically, send_js function should return file either app/js/ or js/ directory. however, removing either of these files causes application 404. (the app serves contents of lower one; touch js/jquery.js in upper folder enough make things work.)
why happen?
since application runs run.py, thinks current directory @ /basefolder, application expects directory @ /basefolder/app.
adding os.chdir("app") run.py fixes this. doesn't explain why app expects different paths @ different locations, though.
Comments
Post a Comment