Disable console messages in Flask server

前端 未结 10 829
旧巷少年郎
旧巷少年郎 2020-11-28 07:42

I have a Flask server running in standalone mode (using app.run()). But, I don\'t want any messages in the console, like

127.0.0.1 - - [15/Feb/2         


        
10条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 08:18

    Late answer but I found a way to suppress EACH AND EVERY CONSOLE MESSAGE (including the ones displayed during an abort(...) error).

    import os
    import logging
    
    logging.getLogger('werkzeug').disabled = True
    os.environ['WERKZEUG_RUN_MAIN'] = 'true'
    

    This is basically a combination of the answers given by Slava V and Tom Wojcik

提交回复
热议问题