示例#1
0
def error(request):
    r = request
    body = Template.render('error.html', r=r)
    header = generate_header(len(body), 404)

    response = header + body
    return response.encode()
示例#2
0
def index(request):
    r = request
    body = Template.render('index.html', r=r)
    header = generate_header(len(body))

    response = header + body
    return response.encode()
示例#3
0
def css(request):
    r = request
    # 获取文件的文件名和路径
    filename = r.args.get('f', 'none.png')
    file = f'static/css/{filename}'
    log(f'GET file info\nname:{filename}\ntype:css\npath:{file}')

    with open(file, 'r') as f:
        body = f.read()
    header = generate_header(content_type=f'text/css')

    response = header + body
    return response.encode()
示例#4
0
def js(request):
    r = request
    # 获取文件的文件名和路径
    filename = r.args.get('f', 'error.js')
    file = f'static/js/{filename}'
    log(f'GET file info\nname:{filename}\ntype:css\npath:{file}')

    with open(file, 'r', encoding='utf-8') as f:
        body = f.read()
    header = generate_header(content_type=f'application/x-javascript')

    response = header + body
    return response.encode()
示例#5
0
def image(request):
    r = request
    # 获取文件的文件名, 后缀名和路径
    filename = r.args.get('f', 'none.png')
    file_type = filename.split('.')[-1]
    file = f'static/{filename}'
    log(f'GET file info\nname:{filename}\ntype:{file_type}\npath:{file}')

    with open(file, 'rb') as f:
        body = f.read()
    header = generate_header(content_type=f'img/{file_type}')

    response = header.encode() + body
    return response