Metadata-Version: 2.4
Name: netscript
Version: 2.0
Summary: toml version
Author: Grey Liedtke
Author-email: grey.liedtke@gmail.com
License-Expression: MIT
Project-URL: Homepage, https://github.com/pypa/sampleproject
Project-URL: Issues, https://github.com/pypa/sampleproject/issues
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: license-file

# NetScript

A simple python script to host a flask server to run python scripts and output over a network.

- Version 2 has been overhauled to provide simple interface page and run multiple scripts, including streamlit.


### URL's

- name
  - file name
- /start/name
- /stop/name
- /status/name
- /log/name

### Usage

```python

"""
example netscript
"""

from netscript.script_server import ScriptSpec, ProcessManager
import sys
import os
from pathlib import Path

CWD = Path.cwd()
JOB_ROOT = Path(os.environ.get("JOB_ROOT", Path(__file__).resolve().parent)).resolve()
PY = sys.executable

pf1 = Path("freeze/library/pylibs/netscript/example_test/script_1.py")
pf2 = Path("stream_tools/stream.py")

scripts = {
    "Print-Loop": ScriptSpec(
        script_file=pf1,
        cmd=[
            PY,
            "-u",
            str(pf1),
        ],
    ),
    "Stream": ScriptSpec(
        script_file=pf2,
        cmd=lambda: [
            PY,
            "-m",
            "streamlit",
            "run",
            str(pf2),
            "--server.headless=true",
            "--server.address=0.0.0.0",
            "--server.port=8501",
        ],
    ),
}

mgr = ProcessManager(JOB_ROOT, scripts, reverse_log=True)
app = mgr.create_flask_app()

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5001)

```
