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

start_weechat.py Raw
1from flask import *
2from subprocess import check_output, CalledProcessError
3
4app = Flask(__name__)
5
6@app.route('/')
7def 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
27if __name__ == "__main__":
28 app.run(port=56788, debug=True)
29