mirror of
https://github.com/kennethreitz-archive/python-install-redirector.git
synced 2026-06-05 07:16:13 +00:00
simple app
This commit is contained in:
@@ -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)
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user