KexAri KexAri - 7 months ago 38
Python Question

I don't need the run() method in a Flask application?

I have a Flask application setup on my linode with a directory structure like so:



from flask import Flask
from main import main
app = Flask(__name__)

like so:

from flask import Blueprint

main = Blueprint('main',__name__)
def hello():
return "Hello World!"

def england():
return "Hello England!"

If I run the app locally there are no issues. If I go to my server address in the web browser I get an internal server error. However if I remove the line:
it works fine. Why is this? Why do I not need the run method?


You should do

if __name__ == '__main__':

The reason is that Apache or NGINX or some other web server loads your app directly on the server but runs flask's internal web-server so you can test your app.