Electricity Price Forecasting Project Code
Electricity Price Forecasting Project Code
import csv
import re
@app.route('/')
def home():
return render_template('index.html')
name = request.form['name']
email = request.form['email']
pwd = request.form['pwd']
cpwd = request.form['cpwd']
phno = request.form['phno']
# print('sss')
if pwd == cpwd:
global sql
sql = "select * from registration where name = '%s' and
email='%s'" %(name,email)
print(sql)
a = cursor.execute(sql)
# print(a)
if(a>0):
return render_template('registration.html',msg = 'invalid')
else:
sql = "insert into registration(name,email,pwd,phno) values
(%s,%s,%s,%s)"
print(sql)
# print('GHGH')
val= (name,email,pwd,phno)
# print('OIJO')
cursor.execute(sql,val)
# print('kjjh')
db.commit()
# print('lkjh')
return render_template('registration.html',msg = 'success')
else:
return render_template('registration.html',msg='mismatch')
return render_template('registration.html')
@app.route('/login',methods=["POST","GET"])
def login():
if request.method == 'POST':
name = request.form['name']
pwd = request.form['pwd']
sql = "select * from registration where name = '%s' and pwd='%s'" %
(name,pwd)
a = cursor.execute(sql)
if a>0:
return render_template('index1.html')
else:
return render_template('login.html',msg = 'invalid')
return render_template('login.html')
@app.route('/admin',methods=["POST","GET"])
# def admin():
# if request.method == "POST":
# name = request.form['name']
# pwd = request.form['pwd']
# if name=='Admin' and pwd == 'admin123':
# return render_template('index1.html')
# else:
# return render_template('admin.html',msg = 'invalid')
# return render_template('admin.html')
@app.route('/index1')
def index():
return render_template('index1.html')
@app.route('/prediction',methods = ['POST','GET'])
def prediction():
# if a>0:
if request.method == "POST":
gfg = request.form['gfg']
gfhc = request.form['gfhc']
ghpsc = request.form['ghpsc']
ghwr = request.form['ghwr']
gor = request.form['gor']
gw = request.form['gw']
tlf = request.form['tlf']
tla = request.form['tla']
time = request.form['time']
values = [[float(gfg), float(gfhc), float(ghpsc), float(ghwr),
float(gor), float(gw), float(tlf), float(tla),float((time))]]
xgbr = xgb.XGBRegressor(learning_rate=0.4, n_estimators=200)
model = xgbr.fit(x_train, y_train)
df_pred = pd.DataFrame(values[0],
index=x_test.columns).transpose()
pred = model.predict(df_pred)
# score = r2_score(y_test, pred)
return render_template('prediction.html',msg = 'success',result
= pred)
return render_template('prediction.html')
# else:
# return render_template('prediction.html',msg = 'fail')
# return render_template('predictions.html')
@app.route('/logout')
def logout():
return render_template('logout.html')
@app.route('/view users')
def view_users():
print('lkmn')
sql1 = "select * from registration"
cursor.execute(sql1)
data = cursor.fetchall()
print(data)
df = pd.read_sql_query(sql1,con=db)
g = re.split(',',data)
print(g)
d = pd.DataFrame(g,columns=['id','name','email','pwd','phno'])
# sql = cursor.execute(sql)
# print()
return render_template('view users.html',table = d)
if __name__ == ('__main__'):
app.run(debug=True)