def dashboard(): if (is_logged_in()): count_dict = database().number_dict() return render_template('dashboard.html', count_dict=count_dict) else: flash('You are not logged in ', 'warning') return redirect(url_for('auth.login'))
def login(): error = None if (request.method == "POST"): doctor_id = request.form["doctor_id"] password = request.form["password"] is_logged_in = database().login(doctor_id, password) if (is_logged_in): return render_template('dashboard.html') else: error = "Invalid credentials" return render_template('login.html', error=error) else: return render_template('login.html', error=error)
from flask import flash, request, Blueprint, render_template, redirect, session, flash, url_for from HM.database import * doctor = Blueprint('doctor', __name__) db = database() def is_logged_in(): if 'username' in session: return True else: return False @doctor.route('/dashboard', methods=['GET', 'POST']) def dashboard(): if (is_logged_in()): count_dict = database().number_dict() return render_template('dashboard.html', count_dict=count_dict) else: flash('You are not logged in ', 'warning') return redirect(url_for('auth.login')) @doctor.route('/patient') def patient(): if (is_logged_in()): data = db.get_all_patient_info_list() return render_template('patient.html', data=data) else: flash('You are not logged in ', 'warning')
# core/views.py from flask import flash, request, Blueprint, Response, abort, render_template, redirect, jsonify # from flask_login import LoginManager, login_user, logout_user, login_required # from collections import defaultdict # import traceback from HM.database import * core = Blueprint('core', __name__) # Initialisation database().__init__ @core.route('/') def index(): # MORE TO COME! return render_template('index.html') @core.route('/login', methods=['GET', 'POST']) def login(): error = None if (request.method == "POST"): doctor_id = request.form["doctor_id"] password = request.form["password"] is_logged_in = database().login(doctor_id, password) if (is_logged_in): return render_template('dashboard.html') else: