Hi this is my first stack post. It's also my first time using Flask. After coding a bit, I found it tedious to refresh my browser each time I made some change in my app.py file or something in template and static.
So I did some research on here to find a way to make the refreshing automatic and found this post from which I learned I need to be in debugging mode, and also this post which showed how to use the livereload library to auto-refresh my browser.
However, I am encountering the following error when I open the link to the server while using livereload:
Traceback (most recent call last):
File "...\learn_flask\env\Lib\site-packages\tornado\web.py", line 1767, in _execute
result = self.prepare()
^^^^^^^^^^^^^^
File "...\learn_flask\env\Lib\site-packages\tornado\web.py", line 3149, in prepare
self.fallback(self.request)
File "...\learn_flask\env\Lib\site-packages\livereload\server.py", line 133, in __call__
WSGIContainer.environ(request), start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: WSGIContainer.environ() missing 1 required positional argument: 'request'
Here is my entire app.py file:
from flask import Flask, render_template
from livereload import Server
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
if __name__ == "__main__":
server = Server(app.wsgi_app)
server.serve()
I run the program by typing python app.py in PowerShell inside VS code.
I'm not sure but I'm suspicious if the versions of the libraries I have using are incompatible with each other. I'm currently using Python 3.12.1, Flask 3.0.2, Livereload 2.6.3, and Tornado 6.4. I also tried using a few different older versions for all those but I began running into different errors.