Created
April 30, 2014 17:22
-
-
Save bkeating/135e74023784ee62e22f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from flask import Flask, jsonify, render_template, request | |
app = Flask(__name__) | |
from subprocess import check_output | |
@app.route('/_add_numbers') | |
def add_numbers(): | |
"""Add two numbers server side, ridiculous but well...""" | |
a = request.args.get('a', 0, type=int) | |
b = request.args.get('b', 0, type=int) | |
return jsonify(result=a + b) | |
@app.route('/itunes/<control>') | |
def itunes_control(control=None): | |
r = check_output(['itunes.sh','%s' % control]) | |
return jsonify(result=r) | |
@app.route('/doorbell/') | |
def doorbell(control=None): | |
r = check_output(['say','someone is at the front desk']) | |
return jsonify(result="someone is here!") | |
@app.route('/df') | |
def disk_space(): | |
r = check_output(['df','-h']) | |
return jsonify(result=r) | |
@app.route('/') | |
def index(): | |
return render_template('index.html') | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment