Forums

PA support for flask extra_files parameter?

Hi there,

Using PA, I've set up a very small webapp which publishes the contents of a json file. This json file is periodically updated via another script, which runs as a task from the Schedule tab.

In order for flask to recognise that this file has been updated (and thus reload it's data) I've been using the extra_files parameter to app.run, as follows:

# app.run(debug=True, use_reloader=True, extra_files=[json_file,])

This works perfectly for the flask instance running locally on my laptop - watching the file and reloading upon change. However, it seems to have no effect when I run the same code under PA. Any thoughts as to why this may be and or/what other options I have to achieve this behaviour?

Thanks!

app.run does not work on PythonAnywhere. You need to reload your web app from the web interface or by touching the WSGI file.

Ahh, got it. Thanks so much for the extremely prompt and helpful reply steering me in the right direction.

Hello,

I'm having the exact same issue. How to implement a simple wsgi touch in my code?

Should this work?

import os
os.utime("/var/www/rodolpheg_pythonanywhere_com_wsgi.py", None)

Thanks!

to clarify, touching your wsgi file also restarts your website. you could just do touch /var/www/rodolpheg_pythonanywhere_com_wsgi.py from the bash console.

I would not recommend putting the webapp restart in your production code.