1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-22 16:12:29 +00:00
senpy/docs/usage.rst

76 lines
1.7 KiB
ReStructuredText
Raw Permalink Normal View History

Usage
-----
The easiest and recommended way is to just use the command-line tool to load your plugins and launch the server.
.. code:: bash
senpy
Or, alternatively:
.. code:: bash
python -m senpy
2016-03-16 17:03:32 +00:00
This will create a server with any modules found in the current path.
Useful command-line options
2016-03-17 09:45:14 +00:00
===========================
2016-03-16 17:03:32 +00:00
2016-03-18 12:05:51 +00:00
In case you want to load modules, which are located in different folders under the root folder, use the next option.
2016-03-16 16:47:18 +00:00
.. code:: bash
python -m senpy -f .
2016-03-16 17:03:32 +00:00
The default port used by senpy is 5000, but you can change it using the option `--port`.
.. code:: bash
python -m senpy --port 8080
Also, the host can be changed where senpy is deployed. The default value is `127.0.0.1`.
.. code:: bash
2016-03-18 12:05:51 +00:00
python -m senpy --host 0.0.0.0
2016-03-16 17:03:32 +00:00
For more options, see the `--help` page.
Alternatively, you can use the modules included in senpy to build your own application.
2016-03-17 09:45:14 +00:00
Senpy server
============
Once the server is launched, there is a basic endpoint in the server, which provides a playground to use the plugins that have been loaded.
2016-03-18 12:05:51 +00:00
In case you want to know the different endpoints of the server, there is more information available in the NIF API section_.
Video example
=============
This video shows how to use senpy through command-line tool.
https://asciinema.org/a/9uwef1ghkjk062cw2t4mhzpyk
Request example in python
=========================
This example shows how to make a request to a plugin.
.. code:: python
import requests
import json
r = requests.get('http://127.0.0.1:5000/api/?algo=rand&i=Testing')
response = r.content.decode('utf-8')
response_json = json.loads(response)
.. _section: http://senpy.readthedocs.org/en/latest/api.html