Skip to content

Instantly share code, notes, and snippets.

@brianv0
Created December 4, 2015 00:40
Show Gist options
  • Select an option

  • Save brianv0/b360fb93d653bb3cd0d4 to your computer and use it in GitHub Desktop.

Select an option

Save brianv0/b360fb93d653bb3cd0d4 to your computer and use it in GitHub Desktop.
Basic Flask App
from flask import Flask
app = Flask(__name__)
from toy import toy_blueprint
app.register_blueprint(toy_blueprint)
if __name__ == '__main__':
app.run()
from flask import Blueprint, request, current_app, make_response
toy_blueprint = Blueprint('toy', __name__)
@toy_blueprint.route('/', methods=['GET'])
def get_root():
return make_response("This is a free and clear response", 200)
@toy_blueprint.route('/protected', methods=['GET'])
def get_protected():
return make_response("This is a protected response", 200)
@brianv0
Copy link
Copy Markdown
Author

brianv0 commented Dec 4, 2015

  1. Download the files
git clone https://gist.github.com/b360fb93d653bb3cd0d4.git
mv b360fb93d653bb3cd0d4 toy
cd toy
  1. Install a virtualenv
cd toy && virtualenv toy_env      # Assumes you have virutalenv installed
source toy_env/bin/activate[.csh] # .csh if used from a c shell
pip install flask
python app.py                     # run it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment