Step – 1(import necessary library)
from flask import (Flask, render_template, request, redirect, session)
import pandas as pd
import plotly.express as px
import matplotlib.pyplot as plt
from flask.helpers import url_for
Step – 2 (configuring your application)
app = Flask(name)
app.secret_key = ‘xyz’
step – 3 (creating a dictionary to store information about users)
user = {“username”: “abc”, “password”: “123”}
Step – 4 (creating route for login)
@app.route(’/’, methods=[‘POST’, ‘GET’])
def login():
if (request.method == ‘POST’):
username = request.form.get(‘username’)
password = request.form.get(‘password’)
if username == user[‘username’] and password == user[‘password’]:
session[‘user’] = username
return redirect(’/New_temp’)
return "<h1>Wrong username or password</h1>"
return render_template("login.html")
Step -5(creating route for dashboard and logout)
@app.route(’/New_temp’)
def home():
if (‘user’ in session and session[‘user’] == user[‘username’]):
return render_template(‘New_temp.html’)
@app.route(’/graph’, methods=[‘POST’])
def graph():
return render_template(‘Machine_graph.html’)
pass
#subprocess.call(‘Machine_graph.html’)
#return home()
return '<h1>You are not logged in.</h1>'
Step -7(run the app)
if name== ‘main’:
app.run(debug=True)