Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save muthuspark/d1c0d567ac295a796b011a5d0fb33b4c to your computer and use it in GitHub Desktop.

Select an option

Save muthuspark/d1c0d567ac295a796b011a5d0fb33b4c to your computer and use it in GitHub Desktop.

Revisions

  1. muthuspark created this gist May 10, 2019.
    18 changes: 18 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    import os
    import requests

    img_to_upload = '/Users/muthukrishnan/Pictures/15566790261881556159500299IMG_20190330_120119.jpg'

    url = "http://localhost:5000/api/document/page-extract"

    uploaded_img_path = ''
    with open(img_to_upload, 'rb') as img:
    name_img = os.path.basename(img_to_upload)
    files = {
    'file': (name_img,img,'multipart/form-data', {'Expires': '0'})
    }
    with requests.Session() as s:
    r = s.post(url,files=files)
    uploaded_img_path = r.json()['image']

    print(uploaded_img_path)