diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py')
-rw-r--r-- | testing/web-platform/tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py new file mode 100644 index 0000000000..675b3fc3eb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py @@ -0,0 +1,17 @@ +import os + +from wptserve.utils import isomorphic_decode + +def main(request, response): + directory = os.path.dirname(isomorphic_decode(__file__)) + + try: + file_name = request.GET.first(b"fn") + content_type = request.GET.first(b"ct") + with open(os.path.join(directory, isomorphic_decode(file_name)), u"rb") as fh: + content = fh.read() + + response.headers.set(b"Content-Type", content_type) + response.content = content + except: + response.set_error(400, u"Not enough parameters or file not found") |