def create_app(config_name: str) -> Flask: app = Flask('api-aset-website') app.config.from_object(config[config_name]) configure_api(app) db.init_app(app) return app
def create_app(config_name): app = Flask('crud_users') app.config.from_object(config[config_name]) # setting MongoEngine db.init_app(app) configure_jwt(app) configure_api(app) return app
from flask_migrate import Migrate from app import app from apps.db import db from apps.models.District import DistrictModel from apps.models.Doctor import DoctorModel from apps.models.MedicalSpeciality import MedicalSpecialityModel from apps.models.Patient import PatientModel from apps.models.Plan import PlanModel from apps.models.PrescriptionType import PrescriptionTypeModel from apps.models.Role import RoleModel from apps.models.UnitsOfMeasure import UnitOfMeasureModel from apps.models.User import UserModel my_app = app db.init_app(my_app) migrate = Migrate(my_app, db) def load_tables(): db.engine.execute("SET @@auto_increment_increment=1;") db.engine.execute("SET @@auto_increment_offset=1;") # District if DistrictModel.query.first() is None: district1 = DistrictModel('Callao', 'CAL') district2 = DistrictModel('Bellavista', 'BEL') district3 = DistrictModel('Carmen De La Legua Reynoso', 'CLR') district4 = DistrictModel('La Perla', 'LPE') district5 = DistrictModel('La Punta', 'LPU') district6 = DistrictModel('Ventanilla', 'VEN')
# -*- coding: utf-8 -*- from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_cors import CORS from routes import bp_list from middlewares import before_request_funcs, after_request_funcs from apps.db import db, SQLALCHEMY_DATABASE_URI app = Flask('tools') # SQLAlchemy config app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app) CORS(app, resources=r'/*') # config before and after request functions pb_before_request_funcs_map = {} pb_after_request_funcs_map = {} for bp in bp_list: pb_before_request_funcs_map[bp.name] = before_request_funcs pb_after_request_funcs_map[bp.name] = after_request_funcs app.before_request_funcs = pb_before_request_funcs_map app.after_request_funcs = pb_after_request_funcs_map # register all blueprints for bp in bp_list: app.register_blueprint(bp) import commands