Skip to main content

Simple Python HTTP Exec Server

Project description

Pypi version example Licence PyPI Downloads Python versions

pywebexec

Simple Python HTTP(S) API/Web Command Launcher

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
$ pywebexec
  • Launch commands with params/view live output/Status using browser pywebexec

all commands output / statuses are available in the executables directory in subdirectory .web_status

features

  • Serve executables in a directory
  • Launch commands with params from web browser or API call
  • Follow live output
  • Stop command
  • Relaunch command
  • HTTPS support
  • HTTPS self-signed certificate generator
  • Basic Auth
  • LDAP(S)
  • Can be started as a daemon (POSIX)
  • uses gunicorn to serve http/https
  • compatible Linux/MacOS

Customize server

$ pywebexec --dir ~/myscripts --listen 0.0.0.0 --port 8080 --title myscripts
$ pywebexec -d ~/myscripts -l 0.0.0.0 -p 8080 -t myscripts

Basic auth

  • single user/password
$ pywebexec --user myuser [--password mypass]
$ pywebexec -u myuser [-P mypass]

Generated password is given if no --pasword option

  • ldap(s) password check / group member
$ 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
$ pywebfs --gencert
$ pywebfs --g
  • Start https server using existing certificate
$ pywebfs --cert /pathto/host.cert --key /pathto/host.key
$ pywebfs -c /pathto/host.cert -k /pathto/host.key

Launch server as a daemon

$ pywebexec start
$ pywebexec status
$ pywebexec stop
  • log of server are stored in directory [.config/].pywebexec/pywebexec_<listen>:<port>.log

Launch command through API

$ curl http://myhost:8080/run_script -H 'Content-Type: application/json' -X POST -d '{ "script_name":"myscript", "param":["param1", ...]}

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 output: str
status: 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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywebexec-1.1.6.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywebexec-1.1.6-py3-none-any.whl (36.1 kB view details)

Uploaded Python 3

File details

Details for the file pywebexec-1.1.6.tar.gz.

File metadata

  • Download URL: pywebexec-1.1.6.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for pywebexec-1.1.6.tar.gz
Algorithm Hash digest
SHA256 c36117d55f499858263e68b65f71a1676e8391ffdb1b3d6c6079409d1cf545a0
MD5 a4f93baed439d8f934592bf878f4c403
BLAKE2b-256 8a09976274f850130186e8a2c80fdfa760caf94b9468b15922094155c99106de

See more details on using hashes here.

File details

Details for the file pywebexec-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: pywebexec-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 36.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for pywebexec-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e625dacdab7a119ba72a77d63cb86a0686cf99078caca92dfad63e82413da0b1
MD5 4a382d8a6b0e8c0b302451e5ad78e66b
BLAKE2b-256 e4e7d03c3b0b9f432534558ff199f7bdd6c919a6fad4c05ead78efc208b1e313

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page