Created
August 20, 2013 00:46
-
-
Save pipex/6275881 to your computer and use it in GitHub Desktop.
Basic server for static files with bottlepy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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