示例#1
0
def create_app(register_all=True):
    app = Flask(__name__,
                static_folder='../static',
                template_folder="../static")
    app.config.from_pyfile("config.py")

    if register_all:
        register_blueprints(app)
        # apply_cors(app)
        db.init_app(app)

    return app
示例#2
0
文件: dev.py 项目: gleisonbs/rosie
def config_db(app):
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///app.db"
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    app.secret_key = "b59dc17d-e6f8-4ad4-8eff-7d1594dd030d"

    JWTManager(app)

    db.init_app(app)

    @app.before_first_request
    def create_tables():
        db.create_all()
示例#3
0
from jose import jwt
from models import Usuario, Pet, Veterinaria, UserVet, Services
from config.db import db
from schemas import ma, UsuarioSchema, PetSchema, VeterinariaSchema, UserVetSchema, ServiceSchema
from flask_migrate import Migrate
from blueprints.usuarios_bp import usuarios
from blueprints.pets_bp import pets
from blueprints.veterinarias_bp import veterinarias
from blueprints.uservet_bp import uservets
from blueprints.servicios_bp import services
from funciones.funciones import *

app = Flask(__name__)
app.config.from_object('config.settings')

db.init_app(app)
ma.init_app(app)
migrate = Migrate(app, db)


@app.errorhandler(AuthError)
def handle_auth_error(ex):
    response = jsonify(ex.error)
    response.status_code = ex.status_code
    return response


#Registro de Rutas
app.register_blueprint(usuarios)
app.register_blueprint(pets)
app.register_blueprint(veterinarias)
示例#4
0
from marshmallow import ValidationError
from dotenv import load_dotenv
from config.db import db
from config.ma import ma
from modules.student.endpoint.student import StudentResource, StudentEnrollResource, StudentGetOfferedSubjectResource, \
    StudentIntentToEnroll, StudentModality, EnrolledData, StudentGetGrades, StudentBilling, \
    StudentCheckIfAlreadyEnrolled, StudentSummary, StudentUpdatePassword, TestingResource

enrollment = Flask(__name__, static_url_path=None)
load_dotenv(".env", verbose=True)
enrollment.config.from_object("dev_config")
enrollment.config.from_envvar("APPLICATION_SETTINGS")

cors = CORS(enrollment, resources={r"/api/*": {"origins": "*"}})
api = Api(enrollment)
db.init_app(enrollment)

ma.init_app(enrollment)
jwt = JWTManager(enrollment)


@enrollment.errorhandler(ValidationError)
def handle_validation_error_marshmallow(err):
    return jsonify(err.messages), 400


@jwt.expired_token_loader
def expire_token_header(error):
    print(error)
    print("Expire na kaluoy")
    print(error)