FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-websocket/examples/echo.py at master · garrows/python-websocket · GitHub
garrows
python-websocket
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-websocket
/
examples
/
echo.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
16 lines (14 loc) · 585 Bytes
Breadcrumbs
python-websocket
/
examples
/
echo.py
Copy path
File metadata and controls
executable file
·
16 lines (14 loc) · 585 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
#!/usr/bin/python
import
sys
,
os
,
asyncore
,
websocket
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
!=
2
:
sys
.
stderr
.
write
(
'usage: %s <message>
\n
'
%
os
.
path
.
abspath
(
__file__
))
sys
.
exit
(
1
)
ws
=
websocket
.
WebSocket
(
'ws://localhost:8080'
,
onopen
=
lambda
:
ws
.
send
(
sys
.
argv
[
1
]),
onmessage
=
lambda
m
:
sys
.
stdout
.
write
(
'Echo: %s
\n
'
%
m
),
onclose
=
lambda
:
sys
.
stdout
.
write
(
'Connection closed.
\n
'
))
try
:
asyncore
.
loop
()
except
KeyboardInterrupt
:
ws
.
close
()
Back
|
FazBrowse Home
|
New Git URL