My question is that are you able to run any code after the
if __name__ == "__main__":
app.run()
in flask. I tried to print something after the above syntax to check and it only appeared after I exited the process. I was unable to find answer to this question.
If yes, please guide me on how to accomplish this. I need to run a block of code after the website has been launched. I am running on localhost if that helps.
PS: I am creating a website that downloads an image from the user's computer, runs a python script and predicts what the thing in the image is and tells whether the object is recyclable or not. This is for a school project. I tried to
print("check")
and, as I use pycharm, stopped the process using the stop button and the following appeared:-
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
check
Process finished with exit code 0
As said by @JonSG and @Chris, I needed to create a route method before the
app.run()
to make the code work. Thanks!