Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route('/get_user_profile_pic', methods=['POST'])
- def get_user_profile_pic():
- 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 Profile_image FROM USER WHERE Email = %s", [email])
- fetched = c.fetchone()['Profile_image']
- print(fetched)
- if(not fetched):
- return "User profile image not found"
- img_dir = "user_profile_pics/"
- img_path = fetched
- #img_path = "user_{:0>{width}}_profile_pic".format(ID,width=11)
- #get image in user_profile_pics
- with open(img_dir + img_path, "rb") as image_file:
- encoded_string = base64.b64encode(image_file.read())
- return encoded_string
- c.close()
- conn.close()
- except Exception as e:
- return str(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement