-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
43 lines (30 loc) · 1.04 KB
/
app.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
33
34
35
36
37
38
39
40
41
42
43
import pickle
import numpy as np
from flask import Flask, request, jsonify, render_template
app = Flask(__name__, static_folder="static")
model = pickle.load(open("RandomForest.pkl", "rb"))
@app.route("/")
def home():
return render_template("index.html")
@app.route('/')
def index():
return render_template('index.html')
@app.route("/about-us")
def about_us():
return render_template("about-us.html")
@app.route("/crop")
def crop():
return render_template("crop.html")
@app.route("/fertilizer")
def fertilizer():
return render_template("fertilizer.html")
@app.route("/crop_prediction", methods=["POST"])
def crop_prediction():
features = [int(x) for x in request.form.values()]
print(features)
input_data = [np.array(features)]
crop_prediction = model.predict(input_data)
crop_name = crop_prediction[0]
return render_template("crop.html", prediction_text = "The crop you should harvest is {}".format(crop_name))
if __name__ == "__main__":
app.run(debug=True)