Skip to content

Commit 86b2fea

Browse files
committed
Add script to check connection status and return its result in status route (#106)
1 parent be85b36 commit 86b2fea

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ def turn(data):
6161

6262
# Bot status (STUB)
6363
def status():
64+
internet_status = subprocess.check_output(["./scripts/check_conn.sh"]).decode('utf-8').replace('\n', '')
65+
6466
return {
6567
"status": "ok",
66-
"internetConnectivity": True,
68+
"internetConnectivity": internet_status,
6769
"temp": "40",
6870
"uptime": "5h",
6971
}

scripts/check_conn.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
4+
5+
if [ $? -eq 0 ]; then
6+
echo "true"
7+
else
8+
echo "false"
9+
fi

0 commit comments

Comments
 (0)