Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joknarf/pywebexec
Simple Python HTTP(S) API/Web Remote executor
https://github.com/joknarf/pywebexec
api remote-command share terminal web webserver website
Last synced: 5 days ago
JSON representation
Simple Python HTTP(S) API/Web Remote executor
- Host: GitHub
- URL: https://github.com/joknarf/pywebexec
- Owner: joknarf
- License: mit
- Created: 2025-01-08T15:09:42.000Z (22 days ago)
- Default Branch: main
- Last Pushed: 2025-01-23T15:18:40.000Z (7 days ago)
- Last Synced: 2025-01-23T15:38:17.461Z (7 days ago)
- Topics: api, remote-command, share, terminal, web, webserver, website
- Language: Python
- Homepage:
- Size: 1.01 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Pypi version](https://img.shields.io/pypi/v/pywebexec.svg)](https://pypi.org/project/pywebexec/)
![example](https://github.com/joknarf/pywebexec/actions/workflows/python-publish.yml/badge.svg)
[![Licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://shields.io/)
[![PyPI Downloads](https://static.pepy.tech/badge/pywebexec)](https://pepy.tech/projects/pywebexec)
[![Python versions](https://img.shields.io/badge/python-3.6+-blue.svg)](https://shields.io/)# pywebexec
Simple Python HTTP(S) API/Web Command Launcher and Terminal sharing## Install
```
$ pip install pywebexec
```## Quick start
* put in a directory the scripts/commands/links to commands you want to expose
* start http server serving current directory executables listening on 0.0.0.0 port 8080
```shell
$ pywebexec -d
```* Launch commands with params/view live output/Status using browser
* Share your terminal output using `pywebexec -d term`all commands output / statuses are available in the executables directory in subdirectory `.web_status`
![pywebexecnew8](https://github.com/user-attachments/assets/b36c98e7-8209-46f9-a320-57f460255bc7)## features
* Serve executables in a directory
* Launch commands with params from web browser or API call
* multiple share terminal output
* Follow live output
* Replay terminal history
* Stop command
* Relaunch command
* HTTPS support
* HTTPS self-signed certificate generator
* Basic Auth
* LDAP(S) password check/group member
* Safe url token generation
* Can be started as a daemon (POSIX)
* Uses gunicorn to serve http/https
* Linux/MacOS compatible## Customize server
```shell
$ pywebexec --dir ~/myscripts --listen 0.0.0.0 --port 8080 --title myscripts
$ pywebexec -d ~/myscripts -l 0.0.0.0 -p 8080 -t myscripts
```## Safe url token
* generate safe url, use the url to access the server
```shell
$ pywebexec -T
$ pywebexec --tokenurl
Starting server:
http://:8080?token=jSTWiNgEVkddeEJ7I97x2ekOeaiXs2mErRSKNxm3DP0
http://x.x.x.x:8080?token=jSTWiNgEVkddeEJ7I97x2ekOeaiXs2mErRSKNxm3DP0
```## Basic auth
* single user/password
```shell
$ pywebexec --user myuser [--password mypass]
$ pywebexec -u myuser [-P mypass]
```
Generated password is given if no `--pasword` option* ldap(s) password check / group member
```shell
$ export PYWEBEXEC_LDAP_SERVER=ldap://ldap.forumsys.com:389
$ export PYWEBEXEC_LDAP_BIND_DN="cn=read-only-admin,dc=example,dc=com"
$ export PYWEBEXEC_LDAP_BIND_PASSWORD="password"
$ export PYWEBEXEC_LDAP_GROUPS="ou=mathematicians,ou=scientists"
$ export PYWEBEXEC_LDAP_USER_ID="uid"
$ export PYWEBEXEC_LDAP_BASE_DN="dc=example,dc=com"
$ pywebexec
```
## HTTPS server* Generate auto-signed certificate and start https server
```shell
$ pywebexec --gencert
$ pywebexec --g
```* Start https server using existing certificate
```shell
$ pywebexec --cert /pathto/host.cert --key /pathto/host.key
$ pywebexec -c /pathto/host.cert -k /pathto/host.key
```## Launch server as a daemon
```shell
$ pywebexec start
$ pywebexec status
$ pywebexec stop
```
* log of server are stored in directory `~/[.config/].pywebexec/pywebexec_:.log`## Launch command through API
```shell
$ curl http://myhost:8080/run_command -H 'Content-Type: application/json' -X POST -d '{ "command":"myscript", "params":["param1", ...]}'
$ curl http://myhost:8080/command_status/
$ curl http://myhost:8080/command_output/ -H "Accept: text/plain"
```## API reference
| method | route | params/payload | returns
|-----------|-----------------------------|--------------------|---------------------|
| POST | /run_command | command: str
params: array[str] | command_id: uuid
message: str |
| POST | /stop_command/command_id | | message: str |
| GET | /command_status/command_id | | command_id: uuid
command: str
params: array[str]
start_time: isotime
end_time: isotime
status: str
exit_code: int
last_output_line: str |
| GET | /command_output/command_id | offset: int | output: str
status: str
links: { next: str } |
| GET | /commands | | array of
command_id: uuid
command: str
start_time: isotime
end_time: isotime
status: str
exit_code: int
last_output_line: str |
| GET | /executables | | array of str |