Skip to content

Instantly share code, notes, and snippets.

@matteoferla
Created October 14, 2015 18:31
Show Gist options
  • Save matteoferla/065ea9bb46e4384426c6 to your computer and use it in GitHub Desktop.
Save matteoferla/065ea9bb46e4384426c6 to your computer and use it in GitHub Desktop.
WSGI serve static issue
elif environ['PATH_INFO'].find('/static') != -1:
#ctype = environ['HTTP_ACCEPT'].split(',')[0]
protoctype=environ['PATH_INFO'].split('.')[-1]
if protoctype =='css':
ctype='text/css'
response_body = open('wsgi'+environ['PATH_INFO'],encoding='utf-8').read().encode('utf-8')
elif protoctype =='js':
ctype='text/javascript'
response_body = open('wsgi'+environ['PATH_INFO'],encoding='utf-8').read().encode('utf-8')
elif protoctype =='ico':
ctype='image/x-icon'
response_body = open('wsgi'+environ['PATH_INFO'],'rb').read()
elif protoctype =='woff2' or protoctype =='woff':
ctype='application/x-font-woff'
response_body = open(environ['PATH_INFO'][1:],'rb').read()
elif protoctype =='ttf':
ctype='application/x-font-TrueType'
response_body = open(environ['PATH_INFO'][1:],'rb').read()
else:
ctype='text/plain'
response_body = open(environ['PATH_INFO'][1:],'rb').read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment