I need some help here. I run the code below (using Python 3.7) from a Ubuntu 18.04.05 LTS terminal (typing python filename.py ) and I can view the results on the web page (http://127.0.0.1:500/)
However when I run the code using Spyder (v4.1.4), I encounter the error below when I include the code line app.config["DEBUG"] = True; the same thing occurs when alternatively, I include the code line app(debug = True) in the if __name__ =='__main__'
statement.
If I remove this line things work.
This question may have been answered before, but I can't unravel the solution from the answers.
app = Flask(__name__)
app.config["DEBUG"] = True
@app.route('/')
def hello():
return 'HELLO'
if __name__=='__main__':
#app.debug = True
app.run()
This is the output from the Python 3.7 interpreter:
* Serving Flask app "__main__" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with inotify reloader
/home/name/anaconda3/bin/python: can't find '__main__' module in /home/name/Documents /name/Contents/Python/flask_project/api'
An exception has occurred, use %tb to see the full traceback.
SystemExit: 1
/home/name/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3425: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
%tb
Traceback (most recent call last):
File "", line 3, in app.run()
File "/home/name/anaconda3/lib/python3.7/site-packages/flask/app.py", line 990, in run run_simple(host, port, self, **options)
File "/home/name/anaconda3/lib/python3.7/site-packages/werkzeug/serving.py", line 1050, in run_simple run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
File "/home/name/anaconda3/lib/python3.7/site-packages/werkzeug/_reloader.py", line 339, in run_with_reloader sys.exit(reloader.restart_with_reloader())
SystemExit: 1