imWildCat / scylla

Intelligent proxy pool for Humans™ to extract content from the internet and build your own Large Language Models in this new AI era
Apache License 2.0
3.97k stars 480 forks source link

Can't access API #65

Open CharlesCCC opened 5 years ago

CharlesCCC commented 5 years ago

Describe the bug Can't access the following API

http://localhost:8899/api/v1/proxies

To Reproduce Steps to reproduce the behavior:

  1. install scylla through pip
  2. run scylla
  3. go to the API URL http://localhost:8899/api/v1/proxies
  4. Internal server error with the following error log
[2019-02-28 14:15:27 -0500] [38860] [ERROR] Traceback (most recent call last):
  File "c:\sandbox\scylla\venv-pipinstall\lib\site-packages\sanic\app.py", line 603, in handle_request
    response = await response
  File "c:\sandbox\scylla\venv-pipinstall\lib\site-packages\scylla\web\server.py", line 107, in api_v1_proxies
    'total_page': math.ceil(count / limit),
  File "c:\sandbox\scylla\venv-pipinstall\lib\site-packages\sanic\response.py", line 194, in json
    return HTTPResponse(dumps(body, **kwargs), headers=headers,
  File "C:\Users\cocai1\AppData\Local\Programs\Python\Python36\lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "C:\Users\cocai1\AppData\Local\Programs\Python\Python36\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Users\cocai1\AppData\Local\Programs\Python\Python36\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Users\cocai1\AppData\Local\Programs\Python\Python36\lib\json\encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'datetime' is not JSON serializable

Expected behavior No error with actual stats

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context python 3.6.8 scylla 1.1.5

CharlesCCC commented 5 years ago

It seems like the issue is at the \scylla\venv-pipinstall\Lib\site-packages\sanic\response.py file.

change the line to the following temp fixed the issue but the date will not showing correctly:

    return HTTPResponse(dumps(body, **kwargs, default=str), headers=headers,
                        status=status, content_type=content_type)

or need use json_dumps here https://github.com/imWildCat/scylla/blob/master/scylla/web/server.py#L102