FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-websocket-server/client.html at development · YYYGH/python-websocket-server · GitHub
YYYGH
python-websocket-server
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-websocket-server
/
client.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
65 lines (52 loc) · 1.44 KB
Breadcrumbs
python-websocket-server
/
client.html
Copy path
File metadata and controls
65 lines (52 loc) · 1.44 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<
html
>
<
head
>
<
title
>
Simple client
</
title
>
<
script
type
="
text/javascript
"
>
var
ws
;
function
init
(
)
{
// Connect to Web Socket
ws
=
new
WebSocket
(
"ws://localhost:9001/"
)
;
// Set event handlers.
ws
.
onopen
=
function
(
)
{
output
(
"onopen"
)
;
}
;
ws
.
onmessage
=
function
(
e
)
{
// e.data contains received string.
output
(
"onmessage: "
+
e
.
data
)
;
}
;
ws
.
onclose
=
function
(
)
{
output
(
"onclose"
)
;
}
;
ws
.
onerror
=
function
(
e
)
{
output
(
"onerror"
)
;
console
.
log
(
e
)
}
;
}
function
onSubmit
(
)
{
var
input
=
document
.
getElementById
(
"input"
)
;
// You can send message to the Web Socket using ws.send.
ws
.
send
(
input
.
value
)
;
output
(
"send: "
+
input
.
value
)
;
input
.
value
=
""
;
input
.
focus
(
)
;
}
function
onCloseClick
(
)
{
ws
.
close
(
)
;
}
function
output
(
str
)
{
var
log
=
document
.
getElementById
(
"log"
)
;
var
escaped
=
str
.
replace
(
/
&
/
,
"&"
)
.
replace
(
/
<
/
,
"<"
)
.
replace
(
/
>
/
,
">"
)
.
replace
(
/
"
/
,
"""
)
;
// "
log
.
innerHTML
=
escaped
+
"<br>"
+
log
.
innerHTML
;
}
</
script
>
</
head
>
<
body
onload
="
init();
"
>
<
form
onsubmit
="
onSubmit(); return false;
"
>
<
input
type
="
text
"
id
="
input
"
>
<
input
type
="
submit
"
value
="
Send
"
>
<
button
onclick
="
onCloseClick(); return false;
"
>
close
</
button
>
</
form
>
<
div
id
="
log
"
>
</
div
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL