0

How to run flask app automatically during windows boot?

I have a simple python app

@app.route("/")
def hello():
    # Login Service
    logging.debug("hello world")
    return "Hello World!"


if __name__ == "__main__":
    app.run()

python app.py runs a web app on http://localhost:5000

I want to start the same automatically during the windows boot.

I am new to python + flask + Windows..

Thirumal
  • 8,280
  • 11
  • 53
  • 103
  • Check this out https://stackoverflow.com/questions/4438020/how-to-start-a-python-file-while-windows-starts . The main difficulty I can see you running into is making sure the current working directory is the directory of the app. – belfner Sep 09 '21 at 16:33

1 Answers1

2

you can create a file run_app.bat in your project directory

@echo off
cls

:top
echo.
echo Starting...
echo.

python app.py

and put a shortcut of this file in windows startup folder : C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

Thirumal
  • 8,280
  • 11
  • 53
  • 103
hakim
  • 61
  • 4