def create_app(config=None) -> Flask:
    locale.setlocale(locale.LC_ALL, "pt_BR.UTF-8")  # set locale
    app = Flask(__name__,
                static_folder="../static",
                template_folder="../templates")

    if config is None:
        config = default_config

    app.config.from_object(config)

    # Extensions
    db.init_app(app)
    migrate.init_app(app, db)
    ma.init_app(app)

    # Blueprints and Namespaces
    app = blueprints_factory.register_blueprints(app)
    api.init_app(app)
    """
    loghandler = RotatingFileHandler(os.path.join(app.config.get("BASEDIR"), "logs", "partyou.log"))
    loghandler.setFormatter(Formatter(
        "%(asctime)s %(levelname)s: %(message)s "
        "[in %(pathname)s:%(lineno)d]"
    ))
    

    app.logger.addHandler(loghandler)
    app.logger.setLevel(logging.INFO)

    app = logger_factory.create_logger(app)
    """
    return app
Esempio n. 2
0
def create_app(app: Flask):
    app.config.from_object(config)
    register_blueprint(app)

    db.init_app(app)
    mail.init_app(app)
    CORS(app)
    return app
Esempio n. 3
0
def create_app(default_settings=None):
    if default_settings is None:
        default_settings = settings
    app = Flask(__name__)
    app.config.from_object(default_settings)
    app.debug = app.config['DEBUG']
    db.init_app(app)
    app.register_blueprint(names_bp, url_prefix='/')
    posts_init_app(app)
    return app
Esempio n. 4
0
def create_app() -> Flask:
    app = Flask(__name__)
    app.config.from_object(settings)

    db.init_app(app)
    migrate.init_app(app, db)
    bcrypt.init_app(app)
    cors.init_app(app)

    route_user(app)
    return app
Esempio n. 5
0
from resources.user_resource import UserRegister
from resources.store_resource import Store, StoreList

# from flask_jwt import JWT

app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get('DATABASE_URL',
                                                       "sqlite:///data.db")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.secret_key = "asdasdsadasdsadasdsadasdsadasdsadasd"
api = Api(app)


@app.before_first_request
def create_table():
    db.create_all()


db.init_app(app)
auth.init_app(app, *[authenticate, identity])
api.add_resource(Item, "/item/<string:name>")
api.add_resource(ItemList, "/items")
api.add_resource(UserRegister, "/register")
api.add_resource(Store, '/store/<string:name>')
api.add_resource(StoreList, '/stores')

if __name__ == '__main__':
    app.run()

# api.add_resource(Item, '/item/<string:name>')
Esempio n. 6
0
from timeit import default_timer

import cherrymoon.ext.tpl_filter
import cherrymoon.view.view
import cherrymoon.view.user
import cherrymoon.view.treehole
import cherrymoon.view.looking
import cherrymoon.view.talk
import cherrymoon.view.admin

import cherrymoon.view.sapi
from cherrymoon.redis.limiter import post_check

app.config.from_object('cherrymoon.config')

db.init_app(app)
db.app = app

@app.before_request
def load_current_user():
    g.user = get_current_user()
    g.starttimer = default_timer()
    g.admin = is_admin()
    #print g.user
    #check if to much post
    if request.method == 'POST' and g.user:
        ip = str(request.remote_addr)
        limit = post_check(ip)
        if not limit:
            return u"你对服务器提交数据的频率过快,系统已经记录了你用户名,这种行为将会导致账号被ban"