Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flask 'hello world' not working

I copy pasted the flask's 'hello world' app from their website and am trying to run it. I get an error message in Chrome saying

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Here is the 'hello world' app straight from flasks website

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

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

What I have tried:

-temporarily disabling Avast!

-disabling windows firewall

-ensuring that the flask module is installed

This was working a couple days ago actually...

like image 459
Kristifer Szabo Avatar asked Dec 06 '22 18:12

Kristifer Szabo


2 Answers

I don't know why but when I change

app.run()

to

app.run(port=4996)

it starts working. No idea why the default port is throwing an error. Oh well.

like image 109
Kristifer Szabo Avatar answered Dec 15 '22 10:12

Kristifer Szabo


from flask import Flask

app = Flask(__name__)


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


if __name__ == '__name__':
    app.run()

app.run(port=5000)
like image 42
Gehan Fernando Avatar answered Dec 15 '22 09:12

Gehan Fernando