Skip to content

Commit

Permalink
check in util
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkaufman committed Jan 25, 2021
1 parent cb6a6a6 commit 5c40486
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import traceback
import json

AUDIO_DIR = os.path.join(os.path.dirname(__file__), "audio")
UPLOAD_FNAME = os.path.join(AUDIO_DIR, "User Upload")

def die500(start_response, e):
# This is slightly sketchy: this assumes we are currently in the middle
# of an exception handler for the exception e (which happens to be
# true.)
trb = traceback.format_exc().encode("utf-8")
start_response('500 Internal Server Error', [
('Content-Type', 'text/plain'),
("Access-Control-Allow-Origin", "*"),
("Access-Control-Max-Age", "86400"),
("Access-Control-Expose-Headers", "X-Audio-Metadata"),
("X-Audio-Metadata", json.dumps({
"kill_client": True,
"message": str(e)
}))])
return trb,

0 comments on commit 5c40486

Please sign in to comment.