dimanche 23 mai 2021

poblems with if __name__ == __main__

I am using flask and trying to make a website. I am a beginner, so it is probably something obvious that I missed When I try to run main.py I get a final output of "No module named main"

code (init.py):

from flask import Flask


def create_app():

    print(f"My name is {__name__}")

    app = Flask(__name__)

    app.config['SECRET_KEY'] = "aerkgjner4385"

    return app

code (main.py):

from Website import create_app


app = create_app()



if __name__ == '__main__':

    app.run(debug=True)

I put the f sting in here to see what the name variable was outputting and it was outputting "Website". Website happens to be one of the folders where the files are stored in:

all of the other files are empty




Aucun commentaire:

Enregistrer un commentaire