Python connector module for Node.JS applications. This packages allows Python functions to be called and process Node.JS JSON request. This packages complements PyConnector module for Node.JS.
Installation
Install using pip
pip install nodeconnector
Python version
Python 3.6+ is required.
Usage
A simple minimal API interface can be created using the following example. Note that handle/resolver functions are executed in a separate thread. Context information can be using nodeconnector.Interface.handle( 'query_type', resolve_function, [ ctx ] ).
This object will be passed to all resolve_function calls and can be used to store information between queries.
# minimal.py
import sys
import time
import argparse
import nodeconnector
# argument parsing, PyConnector automatically sends this
parser = argparse.ArgumentParser( description = 'Python Exposed API' )
parser.add_argument( '--pynodeport', help = 'PyConnector Node.JS query port', default = 24001 )
args = parser.parse_args()
# python version query
def nodeq_version( args, ctx = {} ):
return ( '%d.%d.%d' % ( sys.version_info[ 0 ], sys.version_info[ 1 ], sys.version_info[ 2 ] ) )
# increment value query
def nodeq_increment( args, ctx = {} ):
# return value
ctx[ 'inc' ] += 1
args[ 'value' ] = ctx[ 'inc' ]
return args
# create interface
nodeq = nodeconnector.Interface( )
# queries are executed on a separate thread, a context object can be used to pass data
nodeq.handle( 'pyversion', nodeq_version )
nodeq.handle( 'increment', nodeq_increment, dict( inc = 0 ) )
# launch API
nodeq.listen( port = args.pynodeport )
# wait
while( True ):
time.sleep( 0.001 )
License (MIT)
Copyright (C) 2019 Cristian Dobre .
Release files for nodeconnector 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nodeconnector-1.0.5.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nodeconnector-1.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.8 kB
Release files / nodeconnector-1.0.5.tar.gz
| Download URL | nodeconnector-1.0.5.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5801906ffa8d56d69efb21c1aca86f69889545f34b7d537f7c59d9e4059d81f
|
|
BLAKE2b-256 checksum How to use checksums |
5c581fd3adf89792137b712ff5dcf6cdd3cbbc016bb9a74b59f2806814745925
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.6
|
Release files / nodeconnector-1.0.5-py3-none-any.whl
| Download URL | nodeconnector-1.0.5-py3-none-any.whl |
|---|---|
| Size | 3.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50dda5add706af2e2bfccdbcad7652eb65595ce5ce0e6a683b19372cd484f7d9
|
|
BLAKE2b-256 checksum How to use checksums |
d54cb4369a372b440cdbe9aafe5aa99ee9225ca89cdac15e86ea44b0474f5590
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.6
|