Created
January 28, 2016 06:55
-
-
Save yohanes/7b5d8726957e29336985 to your computer and use it in GitHub Desktop.
Click server
This file contains 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
from flask import Flask, redirect, url_for | |
import os | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
return """ | |
<html><head><title>HDMI switcher</title><style> | |
.btn { | |
font-size: 20px; | |
padding: 10px 20px 10px 20px; | |
margin: 40px; | |
} | |
</style></head> | |
<body> | |
<div> | |
<form action="/click" method="POST"> | |
<input type="submit" value="Switch Port" class="btn"/> | |
</form> | |
</div> | |
</body></html> | |
""" | |
@app.route('/click', methods=['POST']) | |
def click(): | |
os.system('sudo python click.py') | |
return redirect(url_for('index')) | |
if __name__ == '__main__': | |
app.run('0.0.0.0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment