Skip to content

Instantly share code, notes, and snippets.

@fwarren
Created February 8, 2021 19:25
Show Gist options
  • Save fwarren/2afc9b1c688f7885b6320bcffd669b4a to your computer and use it in GitHub Desktop.
Save fwarren/2afc9b1c688f7885b6320bcffd669b4a to your computer and use it in GitHub Desktop.
Simple Python Web Sever to return System information
from itty import get, post, run_itty
import os, subprocess
@get('/env/(?P<name>\w+)')
def lookup_environ_variable(request, name):
return os.environ[name]
@get('/freespace')
def compute_free_disk_space(request):
return subprocess.check_output('df')
@post('myrestart')
def test_post(request):
os.system('resteart')
run_itty(host='0.0.0.0', port=8095)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment