0

My flask code output to the console some data as below. And it includes some important customer information. I want to turn off all stdout from Python/Flask. Is there a way to do it?

127.0.0.1 - - [29/Jan/2018 12:53:30] "GET /index?search_term=term HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2018 12:53:32] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [29/Jan/2018 12:53:32] "GET /favicon.ico HTTP/1.1" 404  

@sam-chats When I tried to use > /dev/null nothing has changed

python3 main.py 
* Running on http://127.0.0.1:9876/ (Press CTRL+C to quit)
127.0.0.1 - - [29/Jan/2018 13:11:52] "GET /index HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2018 13:12:00] "GET /index?search_term=python HTTP/1.1" 200 -

python3 main.py  > /dev/null
* Running on http://127.0.0.1:9876/ (Press CTRL+C to quit)
127.0.0.1 - - [29/Jan/2018 13:12:23] "GET /index?search_term=python HTTP/1.1" 200 -
127.0.0.1 - - [29/Jan/2018 13:12:28] "GET /index?search_term=sssss HTTP/1.1" 200 -
ersinakyuz
  • 31
  • 1
  • 9
  • 1
    https://stackoverflow.com/a/18379764 maybe this is what you're looking for – Aditya Jan 29 '18 at 08:23
  • It's actually Werkzeug that is doing this behind the scenes. Aditya had a good recommendation, though it doesn't really remove all the output--only to limit it to errors. The other choice is to remove all the handlers and stop propagation to the root handler for Werkzeug, or simply setup a logging configuration that drops data on the floor if you don't want logging at all (I don't recommend this, logging is really valuable to have). – John Szakmeister Jan 29 '18 at 11:21

1 Answers1

0

When you start your server program, say main.py, do python main.py > /dev/null

Sam Chats
  • 2,271
  • 1
  • 12
  • 34