Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取网页pogram I的两个错误';我正在用Python制作。使用bcrypt的checkpw函数的内部服务错误和类型错误_Python_Bcrypt - Fatal编程技术网

获取网页pogram I的两个错误';我正在用Python制作。使用bcrypt的checkpw函数的内部服务错误和类型错误

获取网页pogram I的两个错误';我正在用Python制作。使用bcrypt的checkpw函数的内部服务错误和类型错误,python,bcrypt,Python,Bcrypt,我正在尝试制作一个具有注册功能的网页。该网页设置为用户可以在注册页面上插入数据,然后使用pymongo存储该信息。我接下来学习python的课程是让我在本页上使用bcrypt,我遇到了一个类型错误,一直说在检查之前必须对Unicode对象进行编码。我还不太熟悉bcrypt,所以我不知道如何纠正这个问题。另一个不断出现的问题是post注册函数的内部服务错误,输入的信息应该一直发布到该函数。我相信守则中包含该问题的相关章节如下: 一, 我看到的错误特别是TypeError:Unicode对象必须在

我正在尝试制作一个具有注册功能的网页。该网页设置为用户可以在注册页面上插入数据,然后使用pymongo存储该信息。我接下来学习python的课程是让我在本页上使用bcrypt,我遇到了一个类型错误,一直说在检查之前必须对Unicode对象进行编码。我还不太熟悉bcrypt,所以我不知道如何纠正这个问题。另一个不断出现的问题是post注册函数的内部服务错误,输入的信息应该一直发布到该函数。我相信守则中包含该问题的相关章节如下: 一,

  • 我看到的错误特别是TypeError:Unicode对象必须在检查之前编码,以及“HTTP/1.1post/postregistration”-500内部服务器错误。 如果你能帮我找出哪里出了问题,以及如何纠正这些问题,我将不胜感激

    class PostRegistration:
        def POST(self):
            data = web.input()
    
            reg_model = RegisterModel.RegisterModel()
            reg_model.insert_user(data)
            return data.username 
    
    import pymongo
    from pymongo import MongoClient
    import bcrypt
    
    
    class RegisterModel:
        def __init__(self):
            self.client = MongoClient()
            self.db = self.client.codewizard
            self.Users = self.db.users
    
        def insert_user(self, data):
            hashed = bcrypt.hashpw(data.password.encode(), bcrypt.gensalt())
    
            id = self.Users.insert({"username": data.username, "name": data.name, "email": data.email, "password": hashed})
            print("UID is", id)
    
            myuser = self.Users.find_one({"username": data.username})
    
            if bcrypt.checkpw("Random1".encode(), myuser["password"]):
                print("This matches")