Skip to content

Instantly share code, notes, and snippets.

@ojii
Created July 5, 2012 15:25
Show Gist options
  • Save ojii/3054350 to your computer and use it in GitHub Desktop.
Save ojii/3054350 to your computer and use it in GitHub Desktop.
Minimial Flask app for frontend guys

How to run this

First time

  1. Make a virtualenv: virtualenv env
  2. Activate the virtualenv: source env/bin/activate
  3. Install dependencies: pip install -r requirements.txt
  4. Run the server: python app.py
  5. Open website in browser at http://localhost:5000/

After initial setup

  1. Run the server: env/bin/python app.py
  2. Open website in browser at http://localhost:5000/

To render a template in templates/hello/world.html open http://localhost:5000/hello/world.html

# -*- coding: utf-8 -*-
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
@app.route('/<path:path>')
def index(path='index.html'):
return render_template(path)
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--public', action='store_true')
parser.add_argument('--no-debug', dest='debug', action='store_false')
parser.add_argument('--port', default=5000, type=int)
args = parser.parse_args()
host = '0.0.0.0' if args.public else '127.0.0.1'
app.run(debug=args.debug, host=host, port=args.port)
Flask==0.9
Jinja2==2.6
Werkzeug==0.8.3
argparse==1.2.1
wsgiref==0.1.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment