Skip to content

Commit 7dfbd50

Browse files
committed
debug starting mode (with env variables)
1 parent 19c3c2f commit 7dfbd50

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

bin/srv.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,5 +206,9 @@ def answer(topic=None):
206206
return result
207207
return Response(result, mimetype='text/plain')
208208

209-
SRV = WSGIServer((SERVER_ADDRESS, SERVER_PORT), app) # log=None)
210-
SRV.serve_forever()
209+
if 'CHEATSH_PORT' in os.environ:
210+
SRV = WSGIServer((SERVER_ADDRESS, int(os.environ.get('CHEATSH_PORT'))), app) # log=None)
211+
SRV.serve_forever()
212+
else:
213+
SRV = WSGIServer((SERVER_ADDRESS, SERVER_PORT), app) # log=None)
214+
SRV.serve_forever()

lib/get_answer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ def _rewrite_section_name_for_q(query):
471471
topic = "q:" + topic
472472
needs_beautification = True
473473

474-
answer = REDIS.get(topic)
474+
if REDIS:
475+
answer = REDIS.get(topic)
475476
if answer:
476477
answer = answer.decode('utf-8')
477478

@@ -488,8 +489,9 @@ def _rewrite_section_name_for_q(query):
488489
answer = _get_unknown(topic)
489490

490491
# saving answers in the cache
491-
if topic_type not in ["search", "internal", "unknown"]:
492-
REDIS.set(topic, answer)
492+
if REDIS:
493+
if topic_type not in ["search", "internal", "unknown"]:
494+
REDIS.set(topic, answer)
493495

494496
if needs_beautification:
495497
filetype = 'bash'

0 commit comments

Comments
 (0)