I'm a beginner in Flask and we run a simple web app at univeristy where you connect to a localhost and you get a simple Hello World text . However when I try to run the app after the flask app loads with the code below :
* Serving Flask app "my_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: off
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
Then i press CTRL +C to quit and then I try to run my app to connect to the webpage using the command
curl localhost:5000/
and I get the error message :
curl : Prefix of URI not recognised.
At line:1 char:1
+ curl localhost:5000/
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotImplemented: (:) [Invoke-WebRequest], NotSupportedException
+ FullyQualifiedErrorId :
WebCmdletIEDomNotSupportedException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
I have tried changing the command to curl.exe localhost:500/ but the result is the same . I have my code below for the web app :
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
@app.route('/<name>')
def hello_name(name):
return f'Hello {name}!\n'
if __name__ == '__main__':
app.run(host='0.0.0.0')
I would appreciate your help with guiding me to run my app . Thank you in advance.
EDIT: the problem was simply that I would terminate my app without opening a shell to connect to the localhost . Thank you for your responses very much
\system32\drivers\etc\hoststhere needs to be a mapping betweenlocalhostand127.0.0.1. In the meantime, maybe you can access the app fromhttp://127.0.0.1:5000/