-
Notifications
You must be signed in to change notification settings - Fork 10
/
app.py
executable file
·41 lines (32 loc) · 1.08 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import bottle
app = application = bottle.Bottle()
docs_path = os.path.join(os.path.dirname(__file__), 'docs/')
static_path = os.path.join(os.path.dirname(__file__), 'static/')
languages = 'en cn'.split()
@app.get('/')
def index():
bottle.redirect('/docs/dev/')
@app.get('/docs/<version>/')
@app.get('/docs/<version>/<filename:path>')
def docs(version, filename='index.html'):
filename = version + '/' + (filename or 'index.html')
print filename
return bottle.static_file(filename, root=docs_path)
@app.get('/commit/:hash#[a-zA-Z0-9]+#')
def commit(hash):
url = 'https://github.com/bottlepy/bottle/commit/%s'
bottle.redirect(url % hash.lower())
@app.get('/bottle.py')
def download():
url = 'https://github.com/bottlepy/bottle/raw/master/bottle.py'
bottle.redirect(url)
@app.get('/<filename:path>')
def static(filename):
return bottle.static_file(filename, root=static_path)
# Start server
if __name__ == '__main__':
import sys
bottle.run(app, port=int(sys.argv[1]), debug='debug' in sys.argv)