Compare commits

..

2 Commits

Author SHA1 Message Date
pictuga bbada0436a Quick guide to ignore SSL certs 2020-09-27 16:48:22 +02:00
pictuga 039a672f4e wsgi: clean up url reconstruction 2020-09-27 16:28:26 +02:00
2 changed files with 16 additions and 10 deletions

View File

@ -48,6 +48,11 @@ except NameError:
basestring = unicode = str basestring = unicode = str
# uncomment the lines below to ignore SSL certs
#import ssl
#ssl._create_default_https_context = ssl._create_unverified_context
MIMETYPE = { MIMETYPE = {
'xml': ['text/xml', 'application/xml', 'application/rss+xml', 'application/rdf+xml', 'application/atom+xml', 'application/xhtml+xml'], 'xml': ['text/xml', 'application/xml', 'application/rss+xml', 'application/rdf+xml', 'application/atom+xml', 'application/xhtml+xml'],
'rss': ['application/rss+xml', 'application/rdf+xml', 'application/atom+xml'], 'rss': ['application/rss+xml', 'application/rdf+xml', 'application/atom+xml'],

View File

@ -53,12 +53,10 @@ def parse_options(options):
return out return out
def cgi_parse_environ(environ): def get_path(environ):
# get options
if 'REQUEST_URI' in environ: if 'REQUEST_URI' in environ:
# when running on Apache # when running on Apache
url = environ['REQUEST_URI'][1:] url = unquote(environ['REQUEST_URI'][1:])
else: else:
# when using internal server # when using internal server
@ -67,12 +65,19 @@ def cgi_parse_environ(environ):
if environ['QUERY_STRING']: if environ['QUERY_STRING']:
url += '?' + environ['QUERY_STRING'] url += '?' + environ['QUERY_STRING']
return url
def cgi_parse_environ(environ):
# get options
url = get_path(environ)
url = re.sub(r'^/?(cgi/)?(morss.py|main.py)/', '', url) url = re.sub(r'^/?(cgi/)?(morss.py|main.py)/', '', url)
if url.startswith(':'): if url.startswith(':'):
split = url.split('/', 1) split = url.split('/', 1)
raw_options = unquote(split[0]).replace('|', '/').replace('\\\'', '\'').split(':')[1:] raw_options = split[0].replace('|', '/').replace('\\\'', '\'').split(':')[1:]
if len(split) > 1: if len(split) > 1:
url = split[1] url = split[1]
@ -154,11 +159,7 @@ def middleware(func):
def cgi_file_handler(environ, start_response, app): def cgi_file_handler(environ, start_response, app):
" Simple HTTP server to serve static files (.html, .css, etc.) " " Simple HTTP server to serve static files (.html, .css, etc.) "
if 'REQUEST_URI' in environ: url = get_path(environ)
url = environ['REQUEST_URI'][1:]
else:
url = environ['PATH_INFO'][1:]
if url == '': if url == '':
url = 'index.html' url = 'index.html'