1
0
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:
Igor Chubin
2019-01-31 00:32:09 +00:00
parent 19c3c2f8af
commit 7dfbd50d95
2 changed files with 11 additions and 5 deletions
+6 -2
View File
@@ -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
View File
@@ -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'