from functools import wraps import datetime from logging import getLogger from flask import render_template, request, url_for,\ redirect, flash, make_response, Blueprint from app.content.models import BlogPost, RecentPosts, Likes from app.views.wtforms import BlogForm from factory_app import create_app from models.exceptions import NotFound, ValidationError logger = getLogger(__name__) recent_posts = RecentPosts() app = create_app() with app.app_context(): from authentication import * @app.route('/hello_world') @login_required def hello_world(): return render_template('hello_world.html') @app.route('/index') def index(): return 'User is updated'
''' Flask를 실행할 프로그램 factory_app로부터 app의 반환값을 받아서 실행한다 ''' import os from factory_app import create_app app = create_app('dev') # chose test, dev, pro if __name__ == '__main__': # flask_path설정은 app.py일 경우 해주지 않아도 된다 app.run(port='5000', host='0.0.0.0')
from factory_app import create_app app = create_app('test') client = app.test_client() def test_config(): assert app.config['SQL_ADDRESS'] in client.get('/').data.decode('utf8')