Skip to content

Instantly share code, notes, and snippets.

@underhilllabs
Last active August 29, 2015 14:05
Show Gist options
  • Save underhilllabs/c3dacff9c27bd6ab23e8 to your computer and use it in GitHub Desktop.
Save underhilllabs/c3dacff9c27bd6ab23e8 to your computer and use it in GitHub Desktop.
flask notes
from flask import Flask
# create an instance of the Flask class
app = Flask(__name__)
# create a route with the route decorator
# it binds a route to a function
@app.route('/')
def hello():
print "Hello, from Flask!"
# run the app if the module is being called by itself
if __name__ == 'main':
app.run()
# run the app on all IPs
if __name__ == 'main':
app.run(host='0.0.0.0')
# run the app in debug
# will print debug messages
# will automatically restart when code changes
if __name__ == 'main':
app.run(debug=True)
# OR easier to comment out
if __name__ == 'main':
app.debug = True
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment