Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route('/get_user_profile', methods=['POST'])
- def get_user_profile():
- try:
- email = request.form['email']
- conn = MySQLdb.connect(host='localhost', user='muscle', password='some_pass')
- c = conn.cursor(MySQLdb.cursors.DictCursor)
- c.execute('USE muscle2')
- c.execute("""SELECT Email, Name, Height, Weight, Profile_image, Plan FROM USER WHERE Email = %s""", [email])
- fetched = c.fetchone()
- img_dir = "user_profile_pics/"
- img_path = fetched['Profile_image']
- string_img = None
- if img_path != None and os.path.isfile(img_dir + img_path):
- with open(img_dir + img_path, "rb") as image_file:
- string_img = base64.b64encode(image_file.read()).decode()
- fetched['Profile_image'] = string_img
- c.close()
- conn.close()
- return jsonify(fetched)
- except Exception as e:
- return str(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement