def create_app(config=None): app = Flask(__name__) app.config.from_pyfile('config/config.py') app.config.from_envvar('API_CONFIG', silent=True) app.config.update(config or {}) from model import mongo mongo.init_app(app, connect=False) from views.user.controller import user_panel app.register_blueprint(user_panel) from views.settings.controller import settings_panel app.register_blueprint(settings_panel) from views.patient.controller import patient_panel app.register_blueprint(patient_panel) from views.hospital.controller import hospital_panel app.register_blueprint(hospital_panel) from views.dashboard.controller import dashboard_panel app.register_blueprint(dashboard_panel) from views.authentication.controller import auth_panel app.register_blueprint(auth_panel) from model import login_manager login_manager.init_app(app) login_manager.login_view = 'auth_panel.login' login_manager.login_message = 'Please login to access this page.' login_manager.login_message_category = 'warning' return app
from flask import Flask, request, redirect, url_for, render_template, flash, session from model import User, db , bcrypt , login_manager from form import UserForm, RegistrationForm, LoginForm , ReviewForm from flask_login import login_user, logout_user app = Flask(__name__) app.config['SECRET_KEY'] = 'this not secret' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['DEBUG'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@ssword@localhost/flaskProject' login_manager.init_app(app) db.init_app(app) @app.route("/edit") def users(): if 'email' in session: users = User.query.order_by(User.name).all() return render_template('table.html', users=users) return redirect(url_for('dashboard')) @app.route("/") def dashboard(): return render_template('dashboard.html') @app.route("/users/delete", methods=('POST',)) def users_delete(): try: user_index = User.query.filter_by(id=request.form['id']).first() db.session.delete(user_index) db.session.commit()