'Flask - Jquery Load Images from Database

I have all my image path stored in Database

In the Database it is stored as "templates/assets/userdata/visitorimages/4f686593-2c5a-4d9c-b3d9-ad389b3df690.jpg"

My Flask Code

  @visitor_management.route("/getallVisits",methods=['POST'])

def getallVisits(): response={"data":visitor_management_model.getallVisits(),"message":"visits fetched successfully !"} return json.dumps(response)

Model

def getallVisits():
try:
    query="SELECT v.visit_id,v.purpose_of_visit,l.name,IF(v.authorized_by=0,'UNAUTHORISED',a.name),v.visitor_info,v.`status`,v.visitor_photo FROM visit v LEFT JOIN locations l ON v.location = l.id  LEFT JOIN admin a ON a.id = v.authorized_by"
    #query="select visit_id,purpose_of_visit,location,authorized_by,resident_id,status from visit order by in_time desc"
    cur.execute(query)
    output = cur.fetchall()
    return output
except Exception:
    return False

Javascript / Jquery Snippet where the Image is supposed to be loaded

tableData += '<td class="authorizedClass"> <img src="{{url_for("static",filename="'+output[i][6]+'"}}"  /> </td>';

The I get the following error on the browser console.

GET http://localhost:5000/assets/%27%2Boutput%5Bi%5D%5B6%5D%2B%27 404 (NOT FOUND)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source