Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
noVNC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
noVNC
Commits
f6515e3e
Commit
f6515e3e
authored
Apr 07, 2010
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make web.py match README. Remove unused ws_echo.py.
parent
d63e1462
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
53 deletions
+9
-53
web.py
web.py
+9
-1
ws_echo.py
ws_echo.py
+0
-52
No files found.
web.py
View file @
f6515e3e
#!/usr/bin/python
import
sys
from
BaseHTTPServer
import
HTTPServer
from
CGIHTTPServer
import
CGIHTTPRequestHandler
server
=
HTTPServer
((
''
,
8777
),
CGIHTTPRequestHandler
)
try
:
port
=
int
(
sys
.
argv
[
1
])
except
:
print
"
%
s port"
%
sys
.
argv
[
0
]
sys
.
exit
(
2
)
server
=
HTTPServer
((
''
,
port
),
CGIHTTPRequestHandler
)
server
.
serve_forever
()
ws_echo.py
deleted
100755 → 0
View file @
d63e1462
#!/usr/bin/python
import
sys
,
os
,
socket
server_handshake
=
"""HTTP/1.1 101 Web Socket Protocol Handshake
\r
Upgrade: WebSocket
\r
Connection: Upgrade
\r
WebSocket-Origin:
%
s
\r
WebSocket-Location: ws://
%
s
%
s
\r
WebSocket-Protocol: sample
\r
\r
"""
def
start_server
(
port
):
tick
=
0
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
sock
.
bind
((
''
,
port
))
sock
.
listen
(
100
)
while
True
:
try
:
print
'listening on port
%
s'
%
port
csock
,
address
=
sock
.
accept
()
tick
+=
1
print
'Got connection'
handshake
(
csock
,
tick
)
print
'handshaken'
while
True
:
data
=
csock
.
recv
(
255
)
print
'got:
%
s'
%
(
data
)
csock
.
send
(
"
\x00
server response
%
d
\xff
"
%
(
tick
))
tick
+=
1
except
Exception
,
e
:
print
"Ignoring exception:"
,
e
def
handshake
(
client
,
tick
):
handshake
=
client
.
recv
(
255
)
req_lines
=
handshake
.
split
(
"
\r\n
"
)
_
,
path
,
_
=
req_lines
[
0
]
.
split
(
" "
)
_
,
origin
=
req_lines
[
4
]
.
split
(
" "
)
_
,
host
=
req_lines
[
3
]
.
split
(
" "
)
#print "*** got handshake:\n%s" % handshake
print
"*** client origin:
%
s, location: ws://
%
s
%
s"
%
(
origin
,
host
,
path
)
client
.
send
(
server_handshake
%
(
origin
,
host
,
path
))
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
<
2
:
print
"Usage:
%
s <port>"
%
sys
.
argv
[
0
]
sys
.
exit
(
2
)
PORT
=
int
(
sys
.
argv
[
1
])
start_server
(
PORT
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment