ORM编写登陆后,出错。。

西北汉子 数据库进阶-对象关系映射(OR... 最后由 西北汉子 于2017年03月09日回复

  • 2 回答
  • 1.3k 浏览

#main.py

# coding: utf-8

from flask import Flask

from flask import request

from flask import render_template

from flask import redirect

from model import *

app = Flask(__name__)

# 使用flask拓展

from wtforms import Form,TextField,PasswordField,validators

class LoginForm(Form):

username = TextField("username",[validators.Required()])

password = PasswordField("password",[validators.Required()])

@app.route("/register",methods=['GET','POST'])

def register():

myForm = LoginForm(request.form)

if request.method == 'POST':

u=Usernew(myForm.username.data,myForm.password.data)

u.add()

return redirect("http://www.jikexueyuan.com")

return render_template('form.html',form=myForm)

return render_template('form.html',form=myForm)

@app.route("/user",methods=['GET','POST'])

def login():

myForm = LoginForm(request.form)

if request.method=='POST':

u=Usernew(myForm.username.data,myForm.password.data)

if (u.isExisted()):

return redirect("http://www.jikexueyuan.com")

else:

return "Login Failed"

return render_template('form.html',form=myForm)

return render_template('form.html',form=myForm)

if __name__=="__main__":

app.run(port=3306,debug=True)

  • 西北汉子 2017年03月09日 回答 #2楼
  • #1楼  @上海小胖 

    Internal Server Error

    The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

    不能连接到数据库了。model.py咋dos下,可以增加数据和验证,但是,在main函数里,就不行了。

  • 0 评论