46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import urllib.request, json
|
|||
|
|
|
||
|
|
# 1. write-go root (admin page)
|
||
|
|
try:
|
||
|
|
r = urllib.request.urlopen('http://localhost:8016/', timeout=5)
|
||
|
|
body = r.read().decode()
|
||
|
|
print('8016 / :', r.status, 'HTML length:', len(body))
|
||
|
|
except Exception as e:
|
||
|
|
print('8016 / : ERROR -', e)
|
||
|
|
|
||
|
|
# 2. write-go stats
|
||
|
|
try:
|
||
|
|
r = urllib.request.urlopen('http://localhost:8016/api/stats', timeout=5)
|
||
|
|
print('8016 stats:', r.read().decode())
|
||
|
|
except Exception as e:
|
||
|
|
print('8016 stats: ERROR -', e)
|
||
|
|
|
||
|
|
# 3. bot-go health
|
||
|
|
try:
|
||
|
|
r = urllib.request.urlopen('http://127.0.0.1:8017/health', timeout=5)
|
||
|
|
print('8017 health:', r.read().decode())
|
||
|
|
except Exception as e:
|
||
|
|
print('8017 health: ERROR -', e)
|
||
|
|
|
||
|
|
# 4. bot-go status
|
||
|
|
try:
|
||
|
|
r = urllib.request.urlopen('http://127.0.0.1:8017/status', timeout=5)
|
||
|
|
print('8017 status:', r.read().decode())
|
||
|
|
except Exception as e:
|
||
|
|
print('8017 status: ERROR -', e)
|
||
|
|
|
||
|
|
# 5. bot-go start (should say already running)
|
||
|
|
try:
|
||
|
|
req = urllib.request.Request('http://127.0.0.1:8017/start', method='POST')
|
||
|
|
r = urllib.request.urlopen(req, timeout=5)
|
||
|
|
print('8017 start:', r.read().decode())
|
||
|
|
except Exception as e:
|
||
|
|
print('8017 start: ERROR -', e)
|
||
|
|
|
||
|
|
# 6. bot-go stop (just test it works, then restart)
|
||
|
|
try:
|
||
|
|
req = urllib.request.Request('http://127.0.0.1:8017/stop', method='POST')
|
||
|
|
r = urllib.request.urlopen(req, timeout=5)
|
||
|
|
print('8017 stop:', r.read().decode())
|
||
|
|
except Exception as e:
|
||
|
|
print('8017 stop: ERROR -', e)
|