Example #1
def status(name):
    elasticsearch_url = "http://{0}:{1}/".format(ELASTICSEARCH_HOST, ELASTICSEARCH_PORT)
    es_state = requests.get(elasticsearch_url)
    if es_state.status_code == 200:
        return "", 204
Example #2
def login():
    # Here we use a class of some kind to represent and validate our
    # client-side form data. For example, WTForms is a library that will
    # handle this for us, and we use a custom LoginForm to validate.
    form = LoginForm()
    if form.validate_on_submit():
        # Login and validate the user.
        # user should be an instance of your `User` class

        Flask.flash("Logged in successfully.")

        next = Flask.request.args.get("next")
        # next_is_valid should check if the user has valid
        # permission to access the `next` url
        if not next_is_valid(next):
            return Flask.abort(400)

        return Flask.redirect(next or flask.url_for("index"))
    return Flask.render_template("login.html", form=form)