-
Notifications
You must be signed in to change notification settings - Fork 0
/
APi.py
33 lines (22 loc) · 883 Bytes
/
APi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Flask,render_template,request,redirect,jsonify
import pickle
import pandas as pd
import numpy as np
model=pickle.load(open('LinearRegressionModel.pkl','rb'))
app =Flask(__name__)
@app.route('/')
def home():
return"Hello World"
@app.route('/predict',methods=['POST'])
def predict():
name= request.form.get('name')
company= request.form.get('company')
year = request.form.get('year')
fuel_type= request.form.get('fuel_type')
kms_driven= request.form.get('kms_driven')
input_query= pd.DataFrame(columns=['name', 'company', 'year', 'kms_driven', 'fuel_type'],
data=np.array([name, company, year, kms_driven,fuel_type]).reshape(1, 5))
result=model.predict(input_query)[0]
return jsonify({'price':result})
if __name__ == '__main__':
app.run(debug=True,host='192.168.111.210')