simple app

This commit is contained in:
Kenneth Reitz
2012-04-24 13:43:33 -04:00
parent cfb6feeae2
commit 9de421175b
3 changed files with 46 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
web: gunicorn app:app
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
"""
Python-Guide Installer
~~~~~~~~~~~~~~~~~~~~~~
This module provides the core redirector experience.
Doesn't really get much simpler than this.
"""
import httpagentparser
from werkzeug.wsgi import responder
from werkzeug.utils import redirect
LOCATIONS = {
'linux': 'http://docs.python-guide.org/en/latest/starting/install/linux/',
'windows': 'http://docs.python-guide.org/en/latest/starting/install/win/',
'macintosh': 'http://docs.python-guide.org/en/latest/starting/install/osx/',
'default': 'http://docs.python-guide.org/en/latest/index.html'
}
@responder
def app(request, *args):
agent = httpagentparser.detect(request['HTTP_USER_AGENT'])['os']['name'].lower()
url = LOCATIONS.get(agent, LOCATIONS.get('default'))
return redirect(url)
if __name__ == '__main__':
from werkzeug.serving import run_simple
run_simple('localhost', 4000, app)
+7
View File
@@ -0,0 +1,7 @@
Flask==0.8
Jinja2==2.6
Werkzeug==0.8.3
distribute==0.6.24
gunicorn==0.14.2
httpagentparser==1.0.5
wsgiref==0.1.2