A simple http/json wrapper around jedi.
It's only purpose for me is to integrate it with YouCompleteMe allowing to run jedi under python3 and get python3 completions, but that would not exclude other uses :). At the moment not all the API It has been wrapped.
For starting the server, after you have cloned it somewhere:
python /path/to/JediHTTP/jedihttp.py [options]
If not specified, 127.0.0.1 is used.
Listen on PORT. If not specified, will use any available port.
PATH is the path of a JSON file containing a key named hmac_secret
. Its value
will be used as the secret for HMAC Auth and the file will be deleted as soon
as it's read.
I thought JediHTTP as a simple wrapper around Jedi so its JSON API resembles the original python one very much so for more information about what the parameters are and what they represent look at the original docs jedi-plugin-api.
Return a 200 status code if the server is up.
Return a 200 status code if the server is up. Is the same as /healthy
.
Parameters:
{
"source": "def f():\n pass",
"line": 1,
"col": 0,
"path": "/home/user/code/src/file.py"
}
Response:
{
"completions": [
{
"name": "name", // Name of variable/function/class/module.
"description": "A textual description of the object.",
"docstring": "A document string for this completion object.",
"module_path": "/usr/lib/python2.7/os.py", // Shows the file path of a module
"line": 4, // The line where the definition occurs (starting with 1).
"column": 2 // The column where the definition occurs (starting with 0).
},
...
]
}
Parameters:
{
"source": "def f():\n pass",
"line": 1,
"col": 0,
"path": "/home/user/code/src/file.py"
}
Response:
{
"definitions": [
{
"module_path": "/usr/lib/python2.7/os.py", // Shows the file path of a module
"line": 3, // The line where the definition occurs (starting with 1).
"column": 1 // The column where the definition occurs (starting with 0).
"in_builtin_module": false, // Whether this is a builtin module.
"is_keyword": false,
"description": "A description of the Definition object",
"docstring": "A document string for this Definition object.",
}
]
}
Parameters:
{
"source": "def f():\n pass",
"line": 1,
"col": 0,
"path": "/home/user/code/src/file.py"
}
Response:
{
"definitions": [
{
"module_path": "/usr/lib/python2.7/os.py", // Shows the file path of a module
"line": 3, // The line where the definition occurs (starting with 1).
"column": 1 // The column where the definition occurs (starting with 0).
"in_builtin_module": false, // Whether this is a builtin module.
"is_keyword": false,
"description": "A description of the Definition object",
"docstring": "A document string for this Definition object.",
}
]
}
Response:
{
"exception": "ValueError"
"message": "`column` parameter is not in a valid range.",
"traceback": "Traceback ..."
}
status code: 500
If the server is started with the --hmac-file-secret
then the JediHTTP will
require every request and response has to be HMAC signed based on the secred
provided in the file putting the HMAC signature in a header called x-jedihttp-hmac
Assuming ||
stands for concatenation:
-
requests signature: HMAC( HMAC( body ) || HMAC( http method ) || HMAC( request path ) ). For example, HMAC(HMAC('foo') || HMAC('GET') || HMAC('/healthy'))
-
Responses: HMAC( body )
I'm not a python programmer but I'm using this to experiment with python a bit.