Last active
August 29, 2015 14:05
-
-
Save underhilllabs/c3dacff9c27bd6ab23e8 to your computer and use it in GitHub Desktop.
flask notes
This file contains 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
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() |
This file contains 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
# run the app on all IPs | |
if __name__ == 'main': | |
app.run(host='0.0.0.0') | |
This file contains 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
# 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