Forums

Flask middlewares on PA

Hi, I read in the flask tutorial that we should not run code in main. How is it possible then to add flasks middelwares such as in:

if __name__ == '__main__':
    app.wsgi_app = SessionMiddleware(app.wsgi_app, session_opts) ## THIS LINE
    app.run(debug=True)

in this case the second line of code ?

You can do that either in your wsgi file or where you define your application in your code, depending on how you want to structure your code.