0

I have just started learning about Flask. I installed it on a virtual env.

My app.py file looks like this.

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return "Hello World"

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

when i run python app.py in powershell nothing happens and it does nothing. I checked that the python is installed and flask is also installed.

Ujjwal
  • 13
  • 1
  • This is hard to answer without inspecting your computer. Try running `flask run` in powershell, and wait for a few minutes till it says its running on address:port. – Sreekant Shenoy May 19 '21 at 13:19
  • I tried running `set FLASK_APP=app.py` flask run ` it showed and error saying ` Failed to find Flask application or factory in module 'app'. Use 'FLASK_APP=app:name' to specify one. ` – Ujjwal May 19 '21 at 13:40

1 Answers1

1

It's hard to give you an answer because we do not have access to your computer.

  • There may be files or programs interfering with your application.
  • I would recommend reading this blog post about running a Flask application.
  • Alternatively, you could debug your program using Visual Studio Code or another IDE.
  • Try finding the port your program is running on and see if you are viewing that port. Read this similar question for help. For example, try using app.run(port=4996).
davidism
  • 98,508
  • 22
  • 317
  • 288
boetis
  • 1
  • 14
  • I tried running `app.run(port=4996)` still does not work. Could not find the solution in the links either. – Ujjwal May 19 '21 at 13:44
  • A debugged using Visual Code and it ran fine. Now when I am running normally it is creating the route successfully. Thank you. – Ujjwal May 19 '21 at 14:02