FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
easyhttp-python/examples/sync/basic_ping.py at main · slpuk/easyhttp-python · GitHub
slpuk
/
easyhttp-python
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
3
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
easyhttp-python
/
examples
/
sync
/
basic_ping.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (22 loc) · 778 Bytes
Breadcrumbs
easyhttp-python
/
examples
/
sync
/
basic_ping.py
Copy path
File metadata and controls
26 lines (22 loc) · 778 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Simple ping script with EasyHTTP & context manager
import
time
from
easyhttp_python
import
EasyHTTP
def
main
():
# Async context manager whuch initializing EasyHTTP
with
EasyHTTP
(
debug
=
True
,
port
=
5000
)
as
easy
:
try
:
# Pinging device by ID once every 3 seconds
while
True
:
# Bool: True if device is online(sended PONG command)
if
easy
.
ping
(
"ABC123"
):
print
(
f"Device ABC123 is online"
)
else
:
print
(
f"Device ABC123 is offline"
)
time
.
sleep
(
3
)
except
KeyboardInterrupt
:
# Stopping
easy
.
stop
()
except
Exception
as
e
:
print
(
e
)
if
__name__
==
'__main__'
:
main
()
Back
|
FazBrowse Home
|
New Git URL