-1

I am a beginner to flask and I have been trying to run a simple program. For some reasons I am using THONNY as I just could not get flask running in a virtualenv even after so many tries. In thonny it worked without a virtualenv

Coming at the point I wrote a simple code

from flask import Flask

app = Flask(__name__)

@app.route('/')

def index():
    return 'Flask webapp'

if __name__ == "__main__":
    app.run(debug = True)

When I did not pass debug = True the app worked and was started on a localhost but after adding debug it gave me the following error

 * Serving Flask app 'app' (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
 * Restarting with stat
C:\Users\Workstation\AppData\Local\Programs\Thonny\python.exe: No module named thonny.plugins.cpython.app

What could be a possible fix to it? Should I continue using thonny for flask?

4

1 回答 1

1

通过运行(如果使用 Python 3 和使用 linux,则为 pip3)pip install flask - 在终端中安装 Flask。

当你安装flask时,在终端中运行你的代码(如果你使用的是windows,则为py)py filename.py

(如果您使用的是 linux 或 mac,则为 python 或 python3) python filename.py

于 2021-07-14T08:21:34.593 回答