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()
__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()
__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)
__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()