1.0.7 • Published 4 years ago

nodethon v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

NodeThon

Logo

What is NodeThon??

NodeThon is a package, which was created to execute and create in python, without leaving node.js, being able to send data between codes.

Installation

Install NodeThon with npm

  npm install nodethon

How NodeThon Work??

Nodethon works with child process and FS (file system) modules.

Usage/Examples

Sending Data Between Codes

Python to Node.js

Use print(value) to send some data to node.js

const { executePythonCode, pythonCode } = require("nodethon")

var code = new pythonCode
code.writeCode(`
x=2
y=6
print(y + x)
`)
code.executeCode()
.then(data => console.log(data))

Data is stored in array in STRING format.

Node.js to Python

Send a data from node.js to python with concatenation.

const { executePythonCode, pythonCode } = require("nodethon")

var code = new pythonCode
const dir = "./example/list.txt"
const txt = "Hello World!!"

code.writeCode(`
file = open("${dir}", "w")
file.write("${txt}")
file.close()
`)

code.executeCode()

Examples

const { executePythonCode, pythonCode } = require("nodethon")

// example 1 - execute a code
executePythonCode("./example/test.py") // "directory"
.then( data => console.log(data))
.catch( err => console.log(err))

// example 2 - create a code via node.js
var code = new pythonCode
const text = "Hello World!!"
const number = 3

code.writeCode(`
print('${text}' + ' via Python')
x=${number}
print(x)
`)
.then( data => console.log(data))
.catch( err => console.log(err))

License

MIT

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago