from flask import * from subprocess import check_output, CalledProcessError app = Flask(__name__) @app.route('/') def index(): if request.args.get("pw", None) and request.args["pw"] == "somepassword": if "start" in request.args: try: _ = check_output(["pidof", "weechat"]) except CalledProcessError: pass else: _ = check_output(["killall", "weechat"]) _ = check_output(["screen", "-dmS", "irc", "weechat"]) return redirect("https://glowing-bear.github.io/glowing-bear", code=302) elif "stop" in request.args: try: _ = check_output(["killall", "weechat"]) return "Done.\n" except CalledProcessError: return "Nothing to stop.\n" else: return "Go away.\n" if __name__ == "__main__": app.run(port=56788, debug=True)