2016-01-17 19:45:44 +01:00
|
|
|
#!/usr/bin/env python2.7
|
|
|
|
import requests
|
|
|
|
import flask
|
|
|
|
import re
|
2016-11-17 19:27:24 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
with open( os.path.dirname(os.path.realpath(__file__)) + "/beamerip.txt", 'r') as f:
|
|
|
|
beamerip = f.readline()
|
2016-01-17 19:45:44 +01:00
|
|
|
|
|
|
|
app = flask.Flask(__name__)
|
|
|
|
|
|
|
|
@app.route("/")
|
|
|
|
def status():
|
|
|
|
try:
|
2016-11-17 19:27:24 +01:00
|
|
|
res = requests.get("http://"+beamerip+"/tgi/return.tgi?query=info", timeout=1)
|
2016-01-17 19:45:44 +01:00
|
|
|
if "NG" in res.content:
|
|
|
|
return "0"
|
|
|
|
reg_res = re.findall(b"<info>([^<]*)</info>", res.content)
|
|
|
|
status = str(reg_res[0][30:32])
|
|
|
|
if status == "01":
|
|
|
|
return "1"
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
return "0"
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
app.run("0.0.0.0", 5042)
|