Skip to content

Instantly share code, notes, and snippets.

@timelfrink
Last active September 17, 2019 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save timelfrink/3ac4e9a943e85bd356f8975835b70fd4 to your computer and use it in GitHub Desktop.
Save timelfrink/3ac4e9a943e85bd356f8975835b70fd4 to your computer and use it in GitHub Desktop.
from flask import Flask, request, redirect, url_for, flash, jsonify
import numpy as np
import pickle as p
import json
app = Flask(__name__)
@app.route('/api/', methods=['POST'])
def makecalc():
data = request.get_json()
prediction = np.array2string(model.predict(data))
return jsonify(prediction)
if __name__ == '__main__':
modelfile = 'models/final_prediction.pickle'
model = p.load(open(modelfile, 'rb'))
app.run(debug=True, host='0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment