구글코랩) 심플 REST API서버 소스를 공유합니다. (Google Colaboratory, Flask, MySQL, NGROK)

 


... (중략)

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)))

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

댓글

이 블로그의 인기 게시물

[LINUX] CentOS 부팅시 오류 : UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY

[MSSQL] 데이터베이스가 사용 중이어서 배타적으로 액서스할 수 없습니다

구글코랩) 안전Dream 실종아동 등 검색 오픈API 소스를 공유합니다. (구글드라이브연동, 이미지 수집 소스)