Update
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.https://www.sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
||||
@@ -30,4 +30,4 @@ def raise_error() -> bool:
|
||||
|
||||
jsonrpc['raise.error'] = raise_error
|
||||
|
||||
app.run(host='0.0.0.0', debug=True)
|
||||
app.run(host='0.0.0.0', port=5500, debug=True)
|
||||
@@ -1,4 +1,4 @@
|
||||
Flask
|
||||
=====
|
||||
|
||||
.. literalinclude:: flask.py
|
||||
.. literalinclude:: example.py
|
||||
|
||||
19
docs/source/client-usage.py
Normal file
19
docs/source/client-usage.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from jsonrpc.client import Client
|
||||
|
||||
|
||||
request = {
|
||||
"jsonrpc": "2.0",
|
||||
"method": "app.endpoint",
|
||||
"params": {"a": 1, "b": 2},
|
||||
"id": "1"
|
||||
}
|
||||
|
||||
client = Client('http://127.0.0.1:5000/api')
|
||||
response = client(request)
|
||||
|
||||
assert 'result' in response, response['error']['message']
|
||||
if 'result' in response:
|
||||
print(response['result'])
|
||||
elif 'error' in response:
|
||||
print(response['result'])
|
||||
print(response)
|
||||
@@ -1,24 +1,8 @@
|
||||
Использование
|
||||
=============
|
||||
|
||||
.. code-block:: python
|
||||
.. literalinclude:: usage.py
|
||||
|
||||
from jsonrpc import JSONRPC
|
||||
.. literalinclude:: server-usage.py
|
||||
|
||||
|
||||
jsonrpc = JSONRPC()
|
||||
|
||||
@jsonrpc.method('app.endpoint')
|
||||
def app_endpoint(a: int, b: int) -> int:
|
||||
result = a + b
|
||||
return result
|
||||
|
||||
request = {
|
||||
"jsonrpc": "2.0",
|
||||
"method": "app.endpoint",
|
||||
"params": {"a": 1, "b": 2},
|
||||
"id": "1"
|
||||
}
|
||||
response = jsonrpc(request)
|
||||
|
||||
print(response)
|
||||
.. literalinclude:: client-usage.py
|
||||
|
||||
Reference in New Issue
Block a user