def register(): data = request.get_json() username = data.get('username') access_token = create_access_token(identity=username) session['username'] = access_token addUser(username, data.get('password')) return jsonify(status='User successfully created!', token=access_token)
def local(): print(""" Press 1: to check date Press 2: to check cal Press 3: to check ls Press 4: to create user Press 5: to remove user Press 6: to create file Press 7: to delete file Press 8: exit """) print("Enter your choice:", end=' ') ch = input() if int(ch) == 1: utilities.date() elif int(ch) == 2: utilities.cal() elif int(ch) == 3: utilities.list() elif int(ch) == 4: user.addUser() elif int(ch) == 5: user.removeUser() elif int(ch) == 6: file.createFile() elif int(ch) == 7: file.deleteFile() elif int(ch) == 8: os.system('tput setaf 6') print("\n***Thank You***\n") os.system('tput setaf 7') exit() else: os.system('tput setaf 1') print("Invalid Key. Retry") os.system('tput setaf 7') print("Press Any Key To Continue...") input()
async def cd(self, ctx, time, *args): self.servers = await GlobalFunc.read("server_data") server = self.servers[str(ctx.guild.id)] channel = await GlobalFunc.getChannel(ctx.guild.channels, server.channelID) if re.match("^([0][0-9]|[1][0-9]|[2][0-3]):?([0-5][0-9])$", time) is not None: try: if ':' not in time: time = time[:2] + ":" + time[2:] if not args: i = removeCharacters(str(ctx.author.id)) name = ctx.author.mention name = name.replace("!", "") server.list[name] = time if i not in server.users: server = addUser(server, i) server.users[removeCharacters(i)].increment() else: server.users[removeCharacters(i)].increment() await ctx.message.add_reaction("✅") else: names = "" for i in args: if "@" in i and "<" in i: i = i.replace("!", "") server.list[i] = time names += "{}, ".format(str(i)) if removeCharacters(i) not in server.users: server = addUser(server, i) server.users[removeCharacters(i)].increment() else: server.users[removeCharacters(i)].increment() else: server.list[i] = time names += "{}, ".format(i) names = names[:-2] await ctx.message.add_reaction("✅") except Exception as e: print(e) await channel.send("<@154332161737097217> Error: {}".format(e)) await ctx.message.add_reaction("⛔") else: await ctx.send( "I'm afraid something went wrong. Use `!help cd` to see how to use the command." ) await GlobalFunc.write(self.servers, "server_data")
def post(self): # parser arguments parser.add_argument('user', type=str, required=True) parser.add_argument('pw', type=str, required=True) args = parser.parse_args() # Increment id self.user_id = user.getAmt()+1 # Add to db details = (self.user_id, args['user'], args['pw']) user.addUser(details) # Add to USERS dict USERS[int(self.user_id)] = {'Username': args['user'], 'Password': args['pw']} # Remove arguments from parser parser.remove_argument('user') parser.remove_argument('pw') return USERS[self.user_id], 201
def addUser(): value = request.get_json() test = value['test'] time = value['time'] flow = value['flow'] (newport,newPassword) = user.addUser(test, time, flow) data = { 'port':newport, 'password':newPassword } temp = jwt.encode(data, secret) user.addNodesUsers(temp) return json.dumps(data)
def post(self): # parser arguments parser.add_argument('user', type=str, required=True) parser.add_argument('pw', type=str, required=True) args = parser.parse_args() # Increment id self.user_id = user.getAmt() + 1 # Add to db details = (self.user_id, args['user'], args['pw']) user.addUser(details) # Add to USERS dict USERS[int(self.user_id)] = { 'Username': args['user'], 'Password': args['pw'] } # Remove arguments from parser parser.remove_argument('user') parser.remove_argument('pw') return USERS[self.user_id], 201