... (중략)

 

class create_user(Resource):

def get(self):

#return {'status':'success'}

try:

parser = reqparse.RequestParser()

parser.add_argument('uid', type=str)

parser.add_argument('name', type=str)

parser.add_argument('tel', type=str)

parser.add_argument('birthday', type=str)

parser.add_argument('pid', type=str)

args = parser.parse_args()

 

uid = args['uid']

name = args['name']

tel = args['tel']

birthday = args['birthday']

pid = args['pid']

 

# print(uid,name,tel,birthday,pid)

 

conn = pymysql.connect(

host=HOST,

user=USER,

password=PASSWORD,

db=DATABASE,

charset=CHARSET,

port=int(PORT),

cursorclass=pymysql.cursors.DictCursor)

 

# print(conn)

 

cnt = exec_select(conn,uid)

 

if cnt:

return {'StatusCode': '1000', 'Message': 'The account exists'}

else:

exec_insert(conn,uid,name,tel,birthday,pid)

return {'StatusCode': '1100', 'Message': 'You have created an account. ('+uid+')'}

 

except Exception as e:

with open(ERR_URI,'a') as file:

file.write('{} You got an error: {}\n'.format(datetime.today().strftime('%Y-%m-%d %H:%M:%S'),str(e)))

 

소스는 아래의 사이트를 참고하세요

https://github.com/gyunseul9/colabapi

Posted by 앤비
,