2

I want to run a local server which executes as specific script when a GET request to the IP is made, because of that I need to run the server in the background (while a other script is runing too) without printing any stuff. Here is my Code:

from flask import Flask
app = Flask(__name__)

@app.route('/', methods = ['GET'])
def index():
    return "Hello How are you?"

if __name__ == '__main__':
    app.run(port = 5000)

I tried it with Threading but I always get stuck at this Output

When running this code I get this Output:

 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://IP:5000/ (Press CTRL+C to quit)```
Michi
  • 71
  • 1
  • 7

1 Answers1

5

You could use pythonw to run the application in the background:

pythonw -m flask run > log.txt 2>&1

make sure the name of the Python file is app.py.

Paolo
  • 21,270
  • 6
  • 38
  • 69