I have a Flask app which runs Selenium to extract an image through XPATH. The .JPG image is saved to MySQL DB (Binary), then it should be rendered to HTML. The problem is that it isn't rendered.
Any thoughts?
Column Type:
profile_picture = Column(BLOB)
Get the image using Selenium:
profile_picture = WebDriverWait(browser, 2).until(EC.presence_of_element_located((By.XPATH,
"//*[@id='react-root']/section/main/div/button/img")))
src = profile_picture.get_attribute('src')
Save the picture to the DB (MySQL):
settings_db.profile_picture = profile_picture
Fetching the image from the DB:
profile_picture = TABLE.query.filter_by(username=current_user.username).first()
profile_picture = profile_picture.profile_picture
Rendering (FLASK):
return render_template('index.html', profile_picture=profile_picture)
HTML:
<img src="{{ profile_picture }}" alt="User Image">
The image is never displayed and the output in HTML between braces is 'unknown'.