Skip to content

Instantly share code, notes, and snippets.

@pipex
Created August 20, 2013 00:46
Show Gist options
  • Save pipex/6275881 to your computer and use it in GitHub Desktop.
Save pipex/6275881 to your computer and use it in GitHub Desktop.
Basic server for static files with bottlepy
import bottle
from bottle import Bottle, static_file
app = Bottle()
@app.route('')
@app.route('/')
def index():
return static_file('index.html', root='web')
@app.route('/:path#.+#', name='/')
def send_static(path):
"""Configure static routes"""
return static_file(path, root='web')
###########################################
# Web errors
###########################################
@app.error(404)
def Error404(code):
return static_file('404.html', root='web')
############################################
# Application execution
############################################
# The application execution goes at the end so all routes are loaded
def main():
bottle.run(app=app)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment