Example #1
0
#!/usr/bin/env python

from flask_application import app

if __name__ == '__main__':
    if app.debug:
        app.run(debug=True)
    else:
        app.run(host='0.0.0.0')

Example #2
0
#!env python
import sys
from pprint import pprint


def show(obj):
    """Show the dump of the properties of the object."""
    pprint(vars(obj))


if sys.flags.interactive:
    from flask_application import *

    print "Loading Flask App in console mode. Use show(<obj)> to introspect."
elif __name__ == "__main__":
    from flask_application import app

    app.run(host="127.0.0.1", port=8080)
#!env python
import sys
from pprint import pprint

def show(obj):
    '''Show the dump of the properties of the object.'''
    pprint(vars(obj))

if sys.flags.interactive:
    from flask_application import *
    #from flask_application.models import *
    print 'Loading Flask App in console mode. Use show(<obj)> to introspect.'
elif __name__ == '__main__':
    from flask_application import app
    app.debug = True
    app.run(host = "0.0.0.0", port = 8080)
Example #4
0
from flask_application import app
import os

if __name__ == "__main__":
    try:
        # If Flask is running on Docker,
        # use host and port specified in Docker image
        if int(os.environ["DOCKER"]) == 1:
            app.run(host=os.environ["HOST"],
                    port=int(os.environ["PORT"]),
                    debug=True,
                    threaded=True)
    except KeyError:
        # default config
        app.run(host="0.0.0.0", port="8080", debug=False, threaded=True)
Example #5
0
    form = PredictForm()
    # form = YesNoQuestionForm()
    if form.validate_on_submit():
        flash("making prediction for the data given...")
        dictionary = make_dictionary(form)
        output = make_prediction(dictionary)
        text = "Predicted price is {}".format(output)
        return render_template("home.html", form=form, prediction_text=text)
    return render_template("home.html", form=form)


@app.route("/predict", methods=["POST"])
@login_required
def results():

    if not request.json:
        abort(400)

    data = request.get_json(force=True)
    if not validate_json(data):
        abort(422)
    prediction = make_prediction(data)

    return jsonify(prediction)


if __name__ == "__main__":
    app.run()

# curl -u 'eyJhbGciOiJIUzUxMiJ9.InByYXRlZWsi.6pTTZjSXEyyqq_RMPaM53H9B-GMaT7sBZyPucNm-agpuSh4YY6573lUGwMTsTiGHsyuqN9MOKS9F6xWFK_kDYg':'eyJhbGciOiJIUzUxMiJ9.ImZsYXNrIg._s8ubXhQqH_s3RfO4CrPL5keU_s04k-1ZefmdIxtSS3m_aJsY9asSNpZDISjp_hVpvJLEnkislqe42enl8qtnQ' -i -H "Content-Type: application/json" -X POST -d '{"longitude":2, "latitude":2, "housing_median_age":1000, "total_rooms":2, "total_bedrooms":3, "population":5, "households":4, "median_income":10000, "ocean_proximity":"NEAR BAY"}' http://localhost:5000/predict