Example #1
0
    def get(self):
        res = Result()
        names = {}
        sex = self.get_argument("sex")
        if sex == "0":
            # male
            for i in range(8):  # 一次返回8个名字
                index = random.randint(0, len(self.application.maleNames) - 1)
                while index in names.keys():
                    index = random.randint(0,
                                           len(self.application.maleNames) - 1)
                names[index] = self.application.maleNames[index]

        elif sex == "1":
            # female
            for i in range(8):  # 一次返回8个名字
                index = random.randint(0,
                                       len(self.application.femaleNames) - 1)
                while index in names.keys():
                    index = random.randint(
                        0,
                        len(self.application.femaleNames) - 1)
                names[index] = self.application.femaleNames[index]
        res.setData(names)
        self.write(res.getRes())
Example #2
0
    def response(self):
        res = Result()
        data = dict()
        data["sender"] = self.sender
        data["type"] = self.type
        data["content"] = self.content
        data["time"] = self.time

        res.setData(data)
        return res.getRes()