
I needed this recently when I just wanted a quick way to allow a file download on a server locked down pretty tight with no web server available. The fact that bottle is contained a single python script with no external requirements is pretty amazing.
from bottle import *
@route('/')
def index(name='World'):
return 'Hello ' + name
run(host='localhost', port=8080)
However, you must add routes for static files such as style sheets and images. These are things that you may take for granted if you’re used to relying on standalone web servers.
@route('/static/:filename')
def server_static(filename):
return static_file(filename, root='/path')
Even allowing a file download is dead simple:
@route('/download/:fn')
def download(fn):
return static_file(fn, root='/path', download=fn)