@@ -96,9 +96,9 @@ def log_query(ip_addr, found, topic, user_agent):
9696 """
9797 Log processed query and some internal data
9898 """
99- log_entry = "%s %s %s %s" % (ip_addr , found , topic , user_agent )
100- with open (CONFIG ["path.log.queries" ], 'a ' ) as my_file :
101- my_file .write (log_entry .encode ('utf-8' )+ " \n " )
99+ log_entry = "%s %s %s %s\n " % (ip_addr , found , topic , user_agent )
100+ with open (CONFIG ["path.log.queries" ], 'ab ' ) as my_file :
101+ my_file .write (log_entry .encode ('utf-8' ))
102102
103103def get_request_ip (req ):
104104 """
@@ -274,9 +274,13 @@ def answer(topic=None):
274274 return result
275275 return Response (result , mimetype = 'text/plain' )
276276
277+
278+ if '--debug' in sys .argv :
279+ app .debug = True
277280if 'CHEATSH_PORT' in os .environ :
278- SRV = WSGIServer ((CONFIG ['server.bind' ], int (os .environ .get ('CHEATSH_PORT' ))), app ) # log=None)
279- SRV .serve_forever ()
281+ PORT = int (os .environ .get ('CHEATSH_PORT' ))
280282else :
281- SRV = WSGIServer ((CONFIG ['server.bind' ], CONFIG ['server.port' ]), app ) # log=None)
282- SRV .serve_forever ()
283+ PORT = CONFIG ['server.port' ]
284+ SRV = WSGIServer ((CONFIG ['server.bind' ], PORT ), app ) # log=None)
285+ print ("Starting server on {}:{}" .format (SRV .address [0 ], SRV .address [1 ]))
286+ SRV .serve_forever ()
0 commit comments