diff --git a/api/swagger.yaml b/api/swagger.yaml index f138e0f..e4345ce 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -183,6 +183,66 @@ paths: type: string description: Error description + /v2/reqphoto: + post: + summary: Get vehicle photos + description: Get photos of the vehicle by VIN + parameters: + - name: access_code + in: query + required: true + schema: + type: string + description: API access code for authentication + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + vin: + type: string + description: Vehicle Identification Number + example: "1HGCM82633A123456" + responses: + '200': + description: Successful photo retrieval + content: + application/json: + schema: + type: object + properties: + found: + type: boolean + description: Whether photos were found + photos: + type: array + description: List of photo information + items: + type: object + properties: + url: + type: string + description: URL of the photo + type: + type: string + description: Type of photo (FRONT, REAR, SIDE, INTERIOR, etc.) + date: + type: string + format: date + description: Date when photo was taken + '400': + description: Invalid VIN or access code + content: + application/json: + schema: + type: object + properties: + error: + type: string + description: Error description + /restfact: get: summary: Check account balance diff --git a/app.py b/app.py index a786cb2..2dbbca1 100644 --- a/app.py +++ b/app.py @@ -701,7 +701,7 @@ def api_reqimage(): app.logger.debug(json.dumps(ret)) return response - cur.execute('select count(*) from salvagedb.salvage_images where vin = :p1 and fnd = 1' , {'p1':vin.upper()}) + cur.execute('select count(*) from salvagedb.salvage_images where vin = :p1 and fn = 1' , {'p1':vin.upper()}) res = cur.fetchone() img_count = int(res[0]) if img_count<1: @@ -715,19 +715,17 @@ def api_reqimage(): app.logger.debug(json.dumps(ret)) return response else: - #req_id = uuid.uuid4().hex - #cur.execute('select rownum,ipath from salvagedb.salvage_images where vin = :p1 and fnd = 1',{'p1':vin.upper()}) - cur.execute("""select GenImages('{}','{}') uid from dual""".format(access_code, vin.upper())) + cur.execute("""select GenImages('{}','{}') as ui from dual""".format(access_code, vin.upper())) res = cur.fetchall() - req_id = res[0] - cur.execute("""select fake_name from salvage_images_req where req_id = '{}}'""".format(req_id)) + req_id = res[0][0] + cur.execute('select fake_name from salvage_images_req where req_id = :p1', {'p1':req_id}) res = cur.fetchall() images = [] nm = 0 for it in res: images.append({ 'num':nm, - 'url':'https://salimages.salvagedb/{}/{}'.format(req_id, it) + 'url':'https://salimages.salvagedb/{}/{}'.format(req_id, it[0]) }) nm = nm + 1 ret = {'status': 'Image_found', 'Images':images} @@ -736,6 +734,7 @@ def api_reqimage(): status=200, mimetype='application/json' ) + return response diff --git a/templates/database.html b/templates/database.html index b099b79..a6a2cd2 100644 --- a/templates/database.html +++ b/templates/database.html @@ -14,11 +14,10 @@

-
+
- @@ -28,7 +27,6 @@ {% for row in pg %} -
# VIN Make Model
{{ row[0] }} {{ row[1] }} {{ row[2] }} {{ row[3] }}