Skip to content

Instantly share code, notes, and snippets.

@bkeating
Created December 13, 2015 18:12
Show Gist options
  • Save bkeating/acc0fddbb8f661d42586 to your computer and use it in GitHub Desktop.
Save bkeating/acc0fddbb8f661d42586 to your computer and use it in GitHub Desktop.
SysAPI - A Simple Example using bottle.py
from bottle import route, run, template, redirect
import socket
import subprocess
@route('/hello/<name>')
def index(name):
print(subprocess.call(["du", "-sh"]))
return template('<b>Hello {{name}}</b>!', name=name)
@route('/overview')
def index():
hostname = socket.gethostname()
du = subprocess.check_output(['df', '-h'])
subprocess.call(["say", "Vagina"])
return template('overview', hostname=hostname, du=du)
run(port=8000, host='10.0.1.106')
<html>
<head>
<title>System Overview</title>
</head>
<body>
<h1>System Overview</h1>
Host: <strong>{{ hostname }}</strong>
<strong>
<h2>Disk Usage</h2>
<pre>{{ du }}</pre>
</strong>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment