Page 173 - FULL REPORT 30012024
P. 173

return redirect(url_for('result', stroke_risk=stroke_risk,
                        personalized_advice = personalized_advice_str))

                            return render_template('predict.html')

                        @app.route('/result')
                        def result():
                            stroke_risk = request.args.get('stroke_risk', type=float, default=0)

                            personalized_advice_str = request.args.get('personalized_advice',
                        default="[]")
                            personalized_advice = json.loads(personalized_advice_str)


                            return render_template('result.html',
                                                   stroke_risk=stroke_risk, personalized_advice =
                        personalized_advice)

                        @app.route('/information')
                        def information():
                            return render_template('information.html')

                        @app.route('/dashboard')
                        def dashboard():
                            return render_template('dashboard.html')

                        @app.route('/admin/login', methods=['GET', 'POST'])
                        def admin_login():
                            if request.method == 'POST':
                                username = request.form['username']
                                password = request.form['password']

                                if username == admin_username and password == admin_password:
                                    session['admin'] = True
                                    session['admin_logging_in'] = True

                                    flash('You are logged in as an admin.', 'success')
                                    return redirect(url_for('admindashboard'))  # Redirect to
                        admin dashboard on successful login

                                flash('Invalid credentials. Please try again.', 'danger')  # Add
                        this line for failed login

                            return redirect(url_for('adminpage'))  # Redirect to the index page on
                        failed login

                        @app.route('/admin')
                        def adminpage():
                            return render_template('login.html')


                        @app.route('/admin/logout')
                        def admin_logout():
                            if 'admin' in session:
                                                               156
   168   169   170   171   172   173   174   175   176   177   178