Exemple #1
0
def app():
    _app = create_app()
    _app.config['DEBUG'] = True
    _app.config['TESTING'] = True
    _app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
    with _app.test_request_context():
        yield _app
Exemple #2
0
from blog import app
from blog.app import create_app

application = create_app()
if __name__ == "__main__":
    application.run("0.0.0.0")
Exemple #3
0
#!/usr/bin/env python

from blog.app import create_app, db
from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand

app = create_app()
manager = Manager(app)
migrate = Migrate(app, db)


manager.add_command('db', MigrateCommand)
manager.add_command('server', Server(
    host='0.0.0.0', port='4000', use_reloader=True, threaded=True))


@manager.command
def test():
    """Run the unit tests."""
    import subprocess
    code = subprocess.call(['py.test', 'tests', '--verbose'])
    return code


@manager.command
def profile(length=25, profile_dir=None):
    """Start the application under the code profiler."""
    from werkzeug.contrib.profiler import ProfilerMiddleware
    app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length],
                                      profile_dir=profile_dir)
    app.run()
Exemple #4
0
"""Create an application instance."""
from flask.helpers import get_debug_flag

from blog.app import create_app
from blog.config import DevConfig, ProdConfig

CONFIG = DevConfig if get_debug_flag() else ProdConfig

app = create_app(CONFIG)
Exemple #5
0
from datetime import datetime, timedelta
from werkzeug.security import generate_password_hash

from blog.app import db, create_app
from blog.models import Post, Tag, User
from blog.config import Configuration

app = create_app(Configuration)

with app.app_context():
    db.drop_all()
    db.create_all()

    tag1 = Tag(value="искусственный интеллект")
    db.session.add(tag1)

    tag2 = Tag(value="робот")
    db.session.add(tag2)

    tag3 = Tag(value="человечество")
    db.session.add(tag3)

    tag4 = Tag(value="умный дом")
    db.session.add(tag4)

    user = User(user_name="user1",
                first_name="Имя",
                last_name="Фамилия",
                password=generate_password_hash("1234"))
    db.session.add(user)
Exemple #6
0
# @Author  :_kerman jt
# @Time    : 19-12-1 下午3:34

import os
from blog.app import create_app

app = create_app()

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, threaded=True)

Exemple #7
0
from blog.app import create_app

app = create_app('development')

if __name__ == "__main__":
    app.run()
def app():
    """Init the application"""
    return create_app()
Exemple #9
0
 def create_app(self):
     app = create_app(TestConfiguration)
     logging.getLogger("werkzeug").setLevel(logging.ERROR)
     os.environ['WERKZEUG_RUN_MAIN'] = 'true'
     return app