Skip to content

Instantly share code, notes, and snippets.

@yohanes
Created January 28, 2016 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yohanes/7b5d8726957e29336985 to your computer and use it in GitHub Desktop.
Save yohanes/7b5d8726957e29336985 to your computer and use it in GitHub Desktop.
Click server
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