# def post(self,user_id=None):
# params={'user_id':[b'729'],'fstname':[b'acp'],'lstname':[b'acp']}
# print(type(params))
# id = params['user_id'][0].decode()
# print(id)
# user = self.session.query(User).filter(User.user_id==id).update(user_id=params['user_id'],fname=params['fstname'],
# lname=params['lstname'])
# self.session.commit(user)
# return redirect('admin.html')
# ###################################
# def post(self, user_id=None):
# params = {'user_id': [b'729'], 'fstname': [b'acp'], 'lstname': [b'acp']}
# print(type(params))
# user_id = params['user_id'][0].decode()
# print(user_id)
# # Update the record in the database
# self.session.query(User).filter(User.user_id == user_id).update(user_id=params['user_id'],
# fname=params['fstname'], lname=params['lstname'])
# # Commit the changes to the database
# self.session.commit()
# # Re-query the database to get the updated record
# user = self.session.query(User).filter(User.user_id == user_id).one()
# return user
# ##########################
# def post(self, user_id=None):
# params = {'user_id': [b'729'], 'fstname': [b'acp'], 'valid': [b'True']}
# print(type(params))
# id = params['user_id'][0].decode()
# print(id)
# # Update the record in the database
# self.session.query(User).filter(User.user_id == id).update(user_id=params['user_id'],
# fname=params['fstname'], valid=params['valid'])
# # Commit the changes to the database
# self.session.commit()
# # Redirect the user to the admin page
# return redirect('admin.html')
###################
# def post(self, user_id=None):
# params = {'user_id': [b'729'], 'fstname': [b'acp'], 'valid': [b'True']}
# print(type(params))
# id = params['user_id'][0].decode()
# print(id)
# # Update the record in the database
# self.session.query(User).filter(User.user_id == id).update(user_id=params['user_id'][0].decode(),
# fname=params['fstname'][0].decode(),
# valid=params['valid'][0].decode())
# # Commit the changes to the database
# self.session.commit()
# # Redirect the user to the admin page
# return redirect('admin.html')
# ##################################
# def put(self, user_id):
# # Get the data from the request
# first_name = self.get_argument('first_name')
# last_name = self.get_argument('last_name')
# # Create a new Session and update the record in the database
# session = Session()
# session.query(User).filter(User.user_id == user_id).update({'first_name': first_name, 'last_name': last_name})
# session.commit()
par = {'user_id': [b'729'], 'fstname': [b'acp'], 'lstname': [b'acp'],'valid': [b'True']}
params = {key: value[0].decode() for key, value in par.items()}
print(params)
# for key,value in par.items():
# print(key,value)
# key[0]=value
Import files
# How to import class from another file Main |-- animal_def.py |-- file.py # animal_def.py class Animal: def animalName(self,name): print('This is {}'.format(name)) # file.py from animal_def import Animal ani = Animal() im = ani.animalName('Tiger') # How to import all classes from another folder # animal_def.py class Animal: def animalName(self,name): print('This is {}'.format(name)) class Plant: def plantName(self,name): print('this is {}'.format(name)) # file.py from animal_def import * ani = Animal() bni = Plant() im = ani.animalName('Tiger') ik = bni.plantName('Neem') # How to import all classes from another file main |-- module |-- human_def.py |-- run.py main |-- module |-- human_def.py |-- __init__.py |-- run.py # 1st create __init__.py file in from folder # human_def.py class Animal: def animalName(self,name): print('This is {}'.forma...
Comments
Post a Comment