示例#1
0
def test_config_testing():
    app = create_app("testing")
    assert app.config["SECRET_KEY"] != "open sesame"
    assert app.config["TESTING"]
    assert app.config["SQLALCHEMY_DATABASE_URI"] == SQLITE_TEST
    assert app.config["TOKEN_EXPIRE_HOURS"] == 0
    assert app.config["TOKEN_EXPIRE_MINUTES"] == 0
示例#2
0
def test_config_development():
    app = create_app("development")
    assert app.config["SECRET_KEY"] != "open sesame"
    assert not app.config["TESTING"]
    assert app.config["SQLALCHEMY_DATABASE_URI"] == os.getenv(
        "DATABASE_URL", SQLITE_DEV)
    assert app.config["TOKEN_EXPIRE_HOURS"] == 0
    assert app.config["TOKEN_EXPIRE_MINUTES"] == 15
示例#3
0
def test_config_production():
    app = create_app("production")
    assert app.config["SECRET_KEY"] != "open sesame"
    assert not app.config["TESTING"]
    assert app.config["SQLALCHEMY_DATABASE_URI"] == os.getenv(
        "DATABASE_URL", SQLITE_PROD)
    assert app.config["TOKEN_EXPIRE_HOURS"] == 1
    assert app.config["TOKEN_EXPIRE_MINUTES"] == 0
示例#4
0
#! /usr/bin/env python

import os

from flask.ext.script import Manager

from flask_api import create_app, db

app = create_app(os.getenv('FLASK_API_CONFIG', 'default'))
manager = Manager(app)


@manager.shell
def make_shell_context():
    return dict(app=app, db=db)


if __name__ == '__main__':
    manager.run()
示例#5
0
from flask_script import Manager
from flask_api import create_app
from flask_api.extensions import db
from flask_api.user import manager as user_manager

manager = Manager(create_app(register_blueprints=False))


@manager.command
def init_db():
    """
    Initializes the tables in the database
    """
    db.drop_all()
    db.create_all()
    db.session.commit()


manager.add_command("user", user_manager)

if __name__ == "__main__":
    manager.run()
示例#6
0
文件: run.py 项目: Ethik-69/Flask_API
"""Flask CLI/Application entry point."""
import os

import click

from flask_api import create_app, db
from flask_api.models.token_blacklist import BlacklistedToken
from flask_api.models.user import User
from flask_api.models.widget import Widget

app = create_app(os.getenv("FLASK_ENV", "development"))


# This decorator makes the decorated method execute
# when the flask shell command is run.
# https://aaronluna.dev/series/flask-api-tutorial/part-1/#flask-cliapplication-entry-point
@app.shell_context_processor
def shell():
    return {
        "db": db,
        "User": User,
        "BlacklistedToken": BlacklistedToken,
        "Widget": Widget,
    }


@app.cli.command("add-user", short_help="add a new user")
@click.argument("email")
@click.option("--admin",
              is_flag=True,
              default=False,
示例#7
0
from flask_api import create_app

app = create_app()

if __name__ == '__main__':
    app.run()
示例#8
0
def app():
    """ Create main app """
    app = create_app("testing")
    return app