import numpy as np
import pickle
from flask import Flask,request, render_template
app=Flask(__name__,template_folder="templates")
model = pickle.load(open('model.pkl', 'rb'))
@app.route('/', methods=['GET'])
def index():
    return render_template('home.html')
@app.route('/home', methods=['GET'])
def about():
    return render_template('home.html')
@app.route('/pred',methods=['GET'])
def page():
    return render_template('upload.html')
@app.route('/predict', methods=['GET', 'POST'])
def predict():
    input_features = [float(x) for x in request.form.values()]
    features_value = [np.array(input_features)]
    print(features_value)  
    features_name = ['DC_POWER','AC_POWER','AMBIENT_TEMPERATURE','MODULE_TEMPERATURE','IRRADIATION']
    prediction = model.predict(features_value)
    output=prediction[0]    
    print(output)
    return render_template('upload.html', prediction_text='The predicted value of solar power generation is {} watts.'.format((output)))

    
if __name__ == '__main__':
      app.run(host='0.0.0.0', port=5000, debug=False)