Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
369ce905
Commit
369ce905
authored
Dec 07, 2018
by
Madhur Tandon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adhere to flake8
parent
0a72c4ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
pyodide_build/serve.py
pyodide_build/serve.py
+13
-4
No files found.
pyodide_build/serve.py
View file @
369ce905
...
@@ -8,23 +8,31 @@ import pathlib
...
@@ -8,23 +8,31 @@ import pathlib
TEST_PATH
=
pathlib
.
Path
(
__file__
).
parents
[
0
].
resolve
()
TEST_PATH
=
pathlib
.
Path
(
__file__
).
parents
[
0
].
resolve
()
BUILD_PATH
=
TEST_PATH
/
'..'
/
'build'
BUILD_PATH
=
TEST_PATH
/
'..'
/
'build'
class
Handler
(
http
.
server
.
SimpleHTTPRequestHandler
):
class
Handler
(
http
.
server
.
SimpleHTTPRequestHandler
):
def
end_headers
(
self
):
def
end_headers
(
self
):
self
.
send_header
(
'Access-Control-Allow-Origin'
,
'*'
)
self
.
send_header
(
'Access-Control-Allow-Origin'
,
'*'
)
super
().
end_headers
()
super
().
end_headers
()
Handler
.
extensions_map
[
'.wasm'
]
=
'application/wasm'
Handler
.
extensions_map
[
'.wasm'
]
=
'application/wasm'
def
make_parser
(
parser
):
def
make_parser
(
parser
):
parser
.
description
=
(
'Start a server with the supplied build_dir and port.'
)
parser
.
description
=
(
'Start a server with the supplied '
parser
.
add_argument
(
'--build_dir'
,
action
=
'store'
,
type
=
str
,
default
=
BUILD_PATH
,
help
=
'set the build directory'
)
'build_dir and port.'
)
parser
.
add_argument
(
'--port'
,
action
=
'store'
,
type
=
int
,
default
=
8000
,
help
=
'set the PORT number'
)
parser
.
add_argument
(
'--build_dir'
,
action
=
'store'
,
type
=
str
,
default
=
BUILD_PATH
,
help
=
'set the build directory'
)
parser
.
add_argument
(
'--port'
,
action
=
'store'
,
type
=
int
,
default
=
8000
,
help
=
'set the PORT number'
)
return
parser
return
parser
def
server
(
port
):
def
server
(
port
):
httpd
=
socketserver
.
TCPServer
((
''
,
port
),
Handler
)
httpd
=
socketserver
.
TCPServer
((
''
,
port
),
Handler
)
return
httpd
return
httpd
def
main
(
args
):
def
main
(
args
):
build_dir
=
args
.
build_dir
build_dir
=
args
.
build_dir
port
=
args
.
port
port
=
args
.
port
...
@@ -38,7 +46,8 @@ def main(args):
...
@@ -38,7 +46,8 @@ def main(args):
httpd
.
shutdown
()
httpd
.
shutdown
()
sys
.
exit
()
sys
.
exit
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
parser
=
make_parser
(
argparse
.
ArgumentParser
())
parser
=
make_parser
(
argparse
.
ArgumentParser
())
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
main
(
args
)
main
(
args
)
\ No newline at end of file
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