Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mp3wavweb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mp3wavweb
mp3wavweb
Commits
9fefd2e3
Commit
9fefd2e3
authored
Mar 03, 2014
by
Per Cederqvist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use UTF-8 in the HTML code.
parent
5535ce7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
mp3wavweb.py
mp3wavweb.py
+13
-8
No files found.
mp3wavweb.py
View file @
9fefd2e3
...
...
@@ -11,7 +11,7 @@ sys.path.insert(0, os.path.dirname(__file__))
import
mp3wavcfg
def
quote
(
s
):
return
urllib
.
parse
.
quote
(
s
)
return
urllib
.
parse
.
quote
(
s
.
encode
(
"utf-8"
)
)
# Taken from
# http://stackoverflow.com/questions/4579908/cross-platform-splitting-of-path-in-python
...
...
@@ -62,7 +62,8 @@ def process_request(environ, start_response):
if
environ
[
"REQUEST_METHOD"
]
not
in
[
"GET"
,
"POST"
]:
raise
MethodNotAllowed
(
'GET, POST'
)
path
=
environ
[
'PATH_INFO'
]
# Hack: Undo some duplicate utf-8 encoding we somehow end up with.
path
=
environ
[
'PATH_INFO'
].
encode
(
"latin-1"
).
decode
(
"utf-8"
)
# We want a trailing slash at the root.
if
path
==
""
and
environ
.
get
(
"SCRIPT_NAME"
,
""
)
!=
""
:
...
...
@@ -91,10 +92,12 @@ def convert(environ, start_response, ph):
if
environ
[
"REQUEST_METHOD"
]
==
"GET"
:
start_response
(
"200 OK"
,
[(
'Content-Type'
,
'text/html'
)])
return
[
"<html><head><title>Request conversion</title></head>"
"<body><form method=
\"
POST
\"
action=
\"
convert
\"
>"
"<button>Confirm conversion to mp3</button>"
[(
'Content-Type'
,
'text/html;charset=utf-8'
)])
return
[
"<!DOCTYPE HTML PUBLIC
\"
-//W3C//DTD HTML 4.01//EN
\"\n
"
"
\"
http://www.w3.org/TR/html4/strict.dtd
\"
>
\n
"
"<html><head><title>Request conversion</title></head>
\n
"
"<body><form method=
\"
POST
\"
action=
\"
convert
\"
>
\n
"
"<button>Confirm conversion to mp3</button>
\n
"
"</form></body></html>"
]
if
environ
[
"REQUEST_METHOD"
]
!=
"POST"
:
...
...
@@ -240,6 +243,8 @@ def handle_directory(environ, start_response, ph, real_dir):
dirs
.
add
(
fn
)
res
=
io
.
StringIO
()
res
.
write
(
"<!DOCTYPE HTML PUBLIC
\"
-//W3C//DTD HTML 4.01//EN
\"\n
"
)
res
.
write
(
"
\"
http://www.w3.org/TR/html4/strict.dtd
\"
>
\n
"
)
res
.
write
(
"<html>"
)
res
.
write
(
"<head>"
)
res
.
write
(
"</head>"
)
...
...
@@ -283,9 +288,9 @@ def handle_directory(environ, start_response, ph, real_dir):
page
=
res
.
getvalue
()
res
.
close
()
start_response
(
"200 OK"
,
[(
"Content-Type"
,
"text/html"
),
start_response
(
"200 OK"
,
[(
"Content-Type"
,
"text/html
;charset=utf-8
"
),
(
"Content-Length"
,
str
(
len
(
page
)))])
return
[
page
]
return
[
page
.
encode
(
"utf-8"
)
]
def
handle_file
(
environ
,
start_response
,
ph
,
real_file
):
content_type
=
{
".wav"
:
"audio/vnd.wave"
,
...
...
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