mirror of
https://github.com/chubin/cheat.sh.git
synced 2026-06-20 13:16:44 +02:00
debug starting mode (with env variables)
This commit is contained in:
+6
-2
@@ -206,5 +206,9 @@ def answer(topic=None):
|
||||
return result
|
||||
return Response(result, mimetype='text/plain')
|
||||
|
||||
SRV = WSGIServer((SERVER_ADDRESS, SERVER_PORT), app) # log=None)
|
||||
SRV.serve_forever()
|
||||
if 'CHEATSH_PORT' in os.environ:
|
||||
SRV = WSGIServer((SERVER_ADDRESS, int(os.environ.get('CHEATSH_PORT'))), app) # log=None)
|
||||
SRV.serve_forever()
|
||||
else:
|
||||
SRV = WSGIServer((SERVER_ADDRESS, SERVER_PORT), app) # log=None)
|
||||
SRV.serve_forever()
|
||||
|
||||
+5
-3
@@ -471,7 +471,8 @@ def get_answer(topic, keyword, options="", request_options=None): # pylint: disa
|
||||
topic = "q:" + topic
|
||||
needs_beautification = True
|
||||
|
||||
answer = REDIS.get(topic)
|
||||
if REDIS:
|
||||
answer = REDIS.get(topic)
|
||||
if answer:
|
||||
answer = answer.decode('utf-8')
|
||||
|
||||
@@ -488,8 +489,9 @@ def get_answer(topic, keyword, options="", request_options=None): # pylint: disa
|
||||
answer = _get_unknown(topic)
|
||||
|
||||
# saving answers in the cache
|
||||
if topic_type not in ["search", "internal", "unknown"]:
|
||||
REDIS.set(topic, answer)
|
||||
if REDIS:
|
||||
if topic_type not in ["search", "internal", "unknown"]:
|
||||
REDIS.set(topic, answer)
|
||||
|
||||
if needs_beautification:
|
||||
filetype = 'bash'
|
||||
|
||||
Reference in New Issue
Block a user