-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I may be doing something wrong, but can't get the object dispatching to work
(see Mapping python collections builtin methods to REST API patterns).
See the code in py2http/examples/object_dispatch.py:
backend_store = {
'some_key': b'some_value',
'some_other_key': b'some_other_value',
}
handlers = [
dict(
endpoint=backend_store,
name='backend_store',
attr_names=['__iter__', '__getitem__', '__setitem__'],
),
]
from py2http import mk_app
app = mk_app(handlers, publish_openapi=True, publish_swagger=True)
if __name__ == '__main__':
app.run()Running this:
python py2http/examples/object_dispatch.py
Bottle v0.12.25 server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.
And trying it with
import requests
requests.post(
'http://localhost:3030/backend_store',
json={
"_attr_name": "__iter__",
"kwargs": {}
}
)I get:
ConnectionError: HTTPConnectionPool(host='localhost', port=3030): Max retries exceeded with url: [/backend_store](https://file+.vscode-resource.vscode-cdn.net/backend_store) (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x109025ed0>: Failed to establish a new connection: [Errno 61] Connection refused'))
Or:
curl -X 'POST' \
'http://localhost:3030/backend_store' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"_attr_name": "__iter__",
"kwargs": {}
}'
I get
curl: (7) Failed to connect to localhost port 3030 after 4 ms: Couldn't connect to server
Yet the server seems to be responding:
python py2http/examples/object_dispatch.py
Bottle v0.12.25 server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.
127.0.0.1 - - [22/Feb/2024 08:27:40] "GET /swagger HTTP/1.1" 200 1173
127.0.0.1 - - [22/Feb/2024 08:27:40] "GET /swagger/swagger.json HTTP/1.1" 200 553
127.0.0.1 - - [22/Feb/2024 08:38:48] "GET /swagger HTTP/1.1" 200 1173
127.0.0.1 - - [22/Feb/2024 08:38:48] "GET /swagger/swagger.json HTTP/1.1" 200 553
Swagger's message is:
Failed to fetch.
Possible Reasons:
CORS
Network Failure
URL scheme must be "http" or "https" for CORS request.
Metadata
Metadata
Assignees
Labels
No labels