Grobid returning 500 type error

381 Views Asked by At

I am trying to use Grobid which is built in my local machine, but this script is print a 500 error. Whereas it works fine when I do it from the CLI using Curl. Help please!

    import requests

    url = 'http://localhost:8080/processHeaderDocument'
    files={'file': open('file.pdf', 'rb')}
    r = requests.post(url,files=files)
    print r.status_code
1

There are 1 best solutions below

0
Renaud On

That works for me:

import requests

url = 'http://localhost:8080/api/processHeaderDocument'
multipart_form_data = {
    'input': open('file.pdf', 'rb')
}
r = requests.post(url, files=multipart_form_data)

assert response.status_code == 200, response.content
print(response.content)


# extracting xml
from lxml import objectify
root = objectify.fromstring(response.content)
title = root.teiHeader.fileDesc.titleStmt.title