Last active 1454970644

A flask web server to start/stop weechat for a Glowing Bear connection. Intended for people who have push notifications set up in their bouncer that only come through when no clients are connected

Steven Smith revised this gist 1455006644. Go to revision

1 file changed, 28 insertions

start_weechat.py(file created)

@@ -0,0 +1,28 @@
1 + from flask import *
2 + from subprocess import check_output, CalledProcessError
3 +
4 + app = Flask(__name__)
5 +
6 + @app.route('/')
7 + def index():
8 + if request.args.get("pw", None) and request.args["pw"] == "somepassword":
9 + if "start" in request.args:
10 + try:
11 + _ = check_output(["pidof", "weechat"])
12 + except CalledProcessError:
13 + pass
14 + else:
15 + _ = check_output(["killall", "weechat"])
16 + _ = check_output(["screen", "-dmS", "irc", "weechat"])
17 + return redirect("https://glowing-bear.github.io/glowing-bear", code=302)
18 + elif "stop" in request.args:
19 + try:
20 + _ = check_output(["killall", "weechat"])
21 + return "Done.\n"
22 + except CalledProcessError:
23 + return "Nothing to stop.\n"
24 + else:
25 + return "Go away.\n"
26 +
27 + if __name__ == "__main__":
28 + app.run(port=56788, debug=True)
Newer Older