我以前运行的代码现在导致我的主烧瓶应用程序无法运行。
错误来自我的forms.py文件。
Microsoft.Office.Interop.Excel.DLL
在尝试启动main.py文件时,我收到消息:
Microsoft.Office.Interop.Excel.DLL
正如我所说,以前没有返回此错误,我很茫然。
答案 0 :(得分:0)
您可能尚未登录。因此current_user为NoneType。试试:
if current_user: # or current_user.is_active:
a = current_user.database
...
else:
return redirect('/login')
答案 1 :(得分:0)
我已经登录,当问题代码被注释掉时,我的页面显示我已登录。
我通过创建一个创建类的函数来解决该问题: '''
def selectclassform():
class SelectClass(FlaskForm):
a = current_user.database
conn = sqlite3.connect("C:\\Users\\Lenovo\\PycharmProjects\\spacedonline\\"+a)
c = conn.cursor()
c.execute("SELECT Class FROM Students ")
data = c.fetchall()
listofclasses = []
for clas in data:
if clas[0] not in listofclasses:
listofclasses.append(clas[0])
finallist = []
for clas in listofclasses:
finallist.append((clas, clas))
nameofclass=SelectField(u"Name of Class", choices=finallist)
submit= SubmitField("Select")
return (SelectClass)
'''
然后在主apps.py文件中调用该函数:
'''
@app.route("/select", methods=["GET", "POST"])
def selectclass():
if current_user.is_authenticated:
form = selectclassform()()
print(form)
if form.validate_on_submit():
print("valid")
session ["nameofclass"]=form.nameofclass.data
#return printtable(form.nameofclass.data, current_user.database)
return redirect(url_for("validate"))
else:
print("bye")
return render_template("select.html", form=form)
else:
return redirect(url_for("login"))
'''