Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example server using livereload 2.0, Flask, and formic to monitor filesystem changes, re-build files, and run a simple static web server
#!/usr/bin/env python
# simple static Flask fileserving app
# with livereload integration
from flask import Flask
app = Flask(__name__,
def root():
return app.send_static_file("index.html")
# livereload server
from livereload import Server, shell
from formic import FileSet
from os import getcwd, path
def make_livereload_server(wsgi_app):
server = Server(wsgi_app)
watch_patterns = (
build_cmd = "make"
print "Files being monitored:"
cwd = getcwd()
for pattern in watch_patterns:
print "Pattern: ", pattern
for filepath in FileSet(include=pattern):
print "=>", path.relpath(filepath, cwd), build_cmd)
return server
import logging
def main():
# wire livereload to Flask via wsgi
flask_wsgi_app = app.wsgi_app
server = make_livereload_server(flask_wsgi_app)
# serve application
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment