简体   繁体   中英

When i run the flask app i get this error

i am in the flask directory that i made

C:\Users\Saad Mohammed>cd C:\Users\Saad Mohammed\Documents\flask_app

C:\Users\Saad Mohammed\Documents\flask_app>set FLASK_APP=sample_app.ipynb

C:\Users\Saad Mohammed\Documents\flask_app>flask run

and i still get this error

  • Serving Flask app 'sample_app.ipynb' (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: off Usage: flask run [OPTIONS] Try 'flask run --help' for help.

Error: Could not import 'sample_app.ipynb'.

Flask run command work with python scripts(.py), not with jupyter notebooks(.ipynb). So you can rewrite your code from 'sample_app.ipynb' to 'sample_app.py' file. After that specify environment variable FLASK_APP to just 'sample_app' without.py.

export FLASK_APP=sample_app

And finally get running server.

$ flask run
 * Serving Flask app "sample_app"
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

have a nice coding!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM