示例#1
0
    def setUp(self):
        app = create_app({
            'SQLALCHEMY_BINDS': SQLALCHEMY_BINDS,
            'SECRET_KEY': 'secret',
        })
        app.testing = True

        self._ctx = app.app_context()
        self._ctx.push()

        db.init_app(app)

        db.drop_all()
        db.create_all()

        self.app = app
        self.client = app.test_client()
        self.prepare_data()
示例#2
0
文件: _base.py 项目: hiyouth/herovii
    def setUp(self):
        app = create_app({
            'SQLALCHEMY_BINDS': SQLALCHEMY_BINDS,
            'SECRET_KEY': 'secret',
        })
        app.testing = True

        self._ctx = app.app_context()
        self._ctx.push()

        db.init_app(app)

        db.drop_all()
        db.create_all()

        self.app = app
        self.client = app.test_client()
        self.prepare_data()
示例#3
0
文件: run.py 项目: hiyouth/herovii
__author__ = 'bliss'

import sys
from flask_cors import CORS
from herovii import create_app
from herovii.models import db

app = create_app()
CORS(app)


if '--initdb' in sys.argv:
    sys.exit()

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

# 日志记录,当前测试在调试模式下,生成环境需更改为 not app.debug
if not app.debug:
    import logging
    from logging import FileHandler
    file_handler = FileHandler('log.txt')
    file_handler.setLevel(logging.WARNING)
    app.logger.addHandler(file_handler)

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

示例#4
0
文件: run.py 项目: chujieyang/herovii
__author__ = 'bliss'

import sys
from flask import g
from flask_httpauth import HTTPBasicAuth
from herovii import create_app
from herovii.models import db

app = create_app({'DEBUG': True})


def create_database():
    # import fixtures
    with app.app_context():
        db.drop_all()
        db.create_all()
        # fixtures.run()

if '--initdb' in sys.argv:
    create_database()
    sys.exit()

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

# 日志记录,当前测试在调试模式下,生成环境需更改为 not app.debug
if app.debug:
    import logging
    from logging import FileHandler
    file_handler = FileHandler('log.txt')
    file_handler.setLevel(logging.WARNING)
示例#5
0
文件: run.py 项目: hiyouth/herovii
__author__ = 'bliss'

import sys
from flask_cors import CORS
from herovii import create_app
from herovii.models import db

app = create_app()
CORS(app)

if '--initdb' in sys.argv:
    sys.exit()

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

# 日志记录,当前测试在调试模式下,生成环境需更改为 not app.debug
if not app.debug:
    import logging
    from logging import FileHandler
    file_handler = FileHandler('log.txt')
    file_handler.setLevel(logging.WARNING)
    app.logger.addHandler(file_handler)

if __name__ == '__main__':
    app.run()
示例#6
0
__author__ = "bliss"

import sys
from herovii import create_app
from herovii.models import db

app = create_app({"DEBUG": True})


# test for route
@app.route("/-ddd/<int:uid>")
def hello_world(uid):
    return "Hello World!" + "   " + str(uid)


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