# config:utf-8
# file : main\__init__.py
from flask import Blueprint
main_app = Blueprint('main', __name__, template_folder='../views/')
from . import views, errors <- 这行:module level import not at top of file
# coding:utf-8
# file: main\views.py
from flask import url_for, redirect, render_template, session, request, abort, redirect
from app import db
from . import main_app as main <- 这行
@main.route('/test')
def t_test():
return render_template('test.html')
Flask 应用 放到顶层在 views 和 errors 就报 can not import 'main'错误。放到底下吧,就不 PEP 了……
PEP8 – import not at top of file with sys.path