Added support for 404 redirect.

ie. http://domain.com/bbc.co.uk/feed.xml will redirect to http://domain.com/morss.py/bbc.co.uk/feed.xml and work.
master
pictuga 2013-04-16 16:11:34 +02:00
parent af8879049f
commit 7b1c32eac2
2 changed files with 12 additions and 2 deletions

View File

@ -1,2 +1,4 @@
AddHandler cgi-script .py AddHandler cgi-script .py
Options +ExecCGI Options +ExecCGI
ErrorDocument 404 /morss.py

View File

@ -349,9 +349,17 @@ def Gather(data, cachePath):
if __name__ == "__main__": if __name__ == "__main__":
if SERVER: if SERVER:
print 'Status: 200'
print 'Content-Type: text/html\n' print 'Content-Type: text/html\n'
if 'REDIRECT_URL' in os.environ:
url = os.environ['REQUEST_URI'][1:]
else:
url = os.environ['REQUEST_URI'][len(os.environ['SCRIPT_NAME'])+1:] url = os.environ['REQUEST_URI'][len(os.environ['SCRIPT_NAME'])+1:]
url = 'http://' + url.replace(' ', '%20') if not url.startswith('http://') and not url.startswith('https://'):
url = "http://" + url
url = url.replace(' ', '%20')
cache = os.getcwd() + '/cache' cache = os.getcwd() + '/cache'
log(url) log(url)
RSS = Gather(url, cache) RSS = Gather(url, cache)