summaryrefslogtreecommitdiffstats
path: root/pasteme.py
blob: 37f452241a779dbef87993ae6aec47b9d41e52cf (plain)
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
#!/usr/bin/python3

import bottle
import identigen

@bottle.route('/')
def route_root():
    return bottle.template('welcome_page')

@bottle.route('/', method='POST')
def route_paste_post():
    content = bottle.request.forms.get('content')
    return content + ' ' + identigen.generate(content)

@bottle.route('/<pid>')
@bottle.route('/<pid>/<pformat>')
def route_paste_get(pid, pformat='colored'):
    return 'paste: {}, {}'.format(pid, pformat)

if __name__ == '__main__':
    print('I: Starting application with development server')
    bottle.run(host='0.0.0.0', port=8080, debug=True, reloader=True)
else:
    print('I: Starting application as a wsgi application')
    application = bottle.default_app() # application used for wsgi mode