Skip to content

Instantly share code, notes, and snippets.

@bkeating bkeating/app.py
Created Dec 13, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.