Created
November 23, 2020 16:44
-
-
Save nithyadurai87/457c95dec830c3527f5780f289992133 to your computer and use it in GitHub Desktop.
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
import os | |
import json | |
import pandas as pd | |
import numpy | |
from flask import Flask, render_template, request, jsonify | |
from pandas.io.json import json_normalize | |
#from sklearn.externals import joblib | |
import joblib | |
app = Flask(__name__) | |
port = int(os.getenv('PORT', 5600)) | |
@app.route('/') | |
def home(): | |
return render_template('index.html') | |
@app.route('/api/salepricemodel', methods=['POST']) | |
def salepricemodel(): | |
if request.method == 'POST': | |
try: | |
post_data = request.get_json() | |
json_data = json.dumps(post_data) | |
s = pd.read_json(json_data) | |
p = joblib.load("./model.pkl") | |
r = p.predict(s) | |
return str(r) | |
except Exception as e: | |
return (e) | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', port=port, debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment