attendanceproject /应用/ __ init.py __
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app=Flask(__name__)
app.config.from_object('config')
db=SQLAlchemy(app)
from app import dbmodels, routes, forms
attendanceproject /应用/ routes.py
from app import app
from app import db
from flask import render_template,url_for,session,request
import app.forms
@app.route('/index')
def index():
return render_template('index.html')
@app.route('/signin.html',methods=['GET','POST'])
def signin():
form=Signinform()
if request.method=='POST':
if form.validation==False:
flash("Please enter all the fields")
return render_template('signin.html',form=form)
attendanceproject / run.py
from app import app
from app import db
import app.dbmodels
db.create_all()
app.run(debug=True)
错误抛出
Traceback (most recent call last):
File "run.py", line 1, in <module>
from app import app
File "D:\Python projects\attendance project\app\__init__.py", line 11, in <module>
from app import dbmodels, routes, forms
File "D:\Python projects\attendance project\app\routes.py", line 6, in <module>
@app.route('/index')
AttributeError: module 'app' has no attribute 'route'
需要帮助。我无法理解错误!!