-
Notifications
You must be signed in to change notification settings - Fork 0
/
PYTHON API
35 lines (24 loc) · 1020 Bytes
/
PYTHON API
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
33
34
35
#Flask API To Connect ML Model and Android App
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__':
#check network ip by using terminal commands: ifconfig(UBUNTU/MAC)/ipconfig(WINDOWS)
app.run(debug=True,host='192.168.111.210')