summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py
blob: 7cfe6f4cec3bbcbb7df3be31c007d239e84836e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import os

def main(request, response):
    directory = os.path.dirname(__file__)

    try:
        file_name = request.GET.first("fn")
        content_type = request.GET.first("ct")
        with open(os.path.join(directory, file_name), "rb") as fh:
            content = fh.read()

        response.headers.set("Content-Type", content_type)
        response.content = content
    except:
        response.set_error(400, "Not enough parameters or file not found")