0

我正在flask-peewee 中为用户登录、注册和注销创建一个应用程序。所有应用程序都在 url 上正确路由。当我尝试发布数据而不是给出错误时,就会出现问题:-
服务器遇到内部错误并且无法完成您的请求。服务器过载或应用程序出错。还给出一个 TypeError: 'dict' object is not callable。

在 view.py :-

from flask import request, redirect, url_for, render_template, flash
from flask_peewee.utils import get_object_or_404, object_list
from app import app
from models import User
from auth import *


@app.route('/join/' , methods=['GET','POST'])
def join(): 

    if request.method == 'POST' and request.form['username']:
        try:
            user = User.select().where(User.username==request.form['username']).get()
            flash('That username is already taken')
        except User.DoesNotExist:       
            user = User(
                username = request.form['username'],
                email = request.form['email'] )
            user.set_password(request.form['password'] )
            user.save()
            auth.login_user(user)
            return 'dua me yaad rakhna'
#           return render_template('home')
#   else:
#       return 'HAAN G DEKHYa fer'

    return render_template("join.html")

在models.py:-

from hashlib import md5, sha1
import datetime

from flask_peewee.auth import BaseUser
from peewee import *
from app import db



class User(BaseUser):
    username = CharField()
    password = CharField()
    email = CharField()


    class Meta:
        order_by = ('username',) 

main.py:-

from views import *
from app import app
from auth import *



if __name__ == '__main__':
    app.run(debug=True)

应用程序.py :-

from flask import Flask
from flask_peewee.db import Database

app = Flask(__name__)
app.config.from_object('config.Configuration')

db = Database(app)


def create_tables():
    User.create_table()

route.py 和 auth.py 也被定义,但它不能显示任何输出。发生错误。

4

0 回答 0