Skip to content

Can i use it as a REST api in Python? #8

@pras135

Description

@pras135

Your repository is working for me as a web app. I am able to host it my local machine. But I was unable to use it as a REST api.
I am using the following code for the same.

url = 'http://localhost:8080'
data = {"q":'subject has headache with fever',
       "format":'html'}
headers = {'Content-Type': 'text'}
response = requests.post(url, data = data, headers = heasders)
response.raise_for_status()
response.json()

And it gives the following error:

JSONDecodeError Traceback (most recent call last)
in
7 response = requests.post(url, data = data)
8 response.raise_for_status()
----> 9 response.json()

C:\ProgramData\Anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs)
895 # used.
896 pass
--> 897 return complexjson.loads(self.text, **kwargs)
898
899 @Property

C:\ProgramData\Anaconda3\lib\json_init_.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
346 parse_int is None and parse_float is None and
347 parse_constant is None and object_pairs_hook is None and not kw):
--> 348 return _default_decoder.decode(s)
349 if cls is None:
350 cls = JSONDecoder

C:\ProgramData\Anaconda3\lib\json\decoder.py in decode(self, s, _w)
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):

C:\ProgramData\Anaconda3\lib\json\decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Is it that the way that I am calling is incoorect? In that case, what would be right format?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions