mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-15 07:34:27 -04:00
fix: Improve headers handling
This commit is contained in:
parent
a40af98ced
commit
62ed11a5ca
6 changed files with 60 additions and 3 deletions
|
@ -2,7 +2,7 @@ from os.path import abspath
|
|||
from os import getcwd
|
||||
from pathlib import Path
|
||||
|
||||
from bottle import route, run, static_file, response
|
||||
from bottle import route, run, static_file, response, redirect
|
||||
|
||||
@route("/")
|
||||
def index():
|
||||
|
@ -30,5 +30,25 @@ def static_path_with_headers(filename):
|
|||
response.add_header("Content-Style-Type", "text/css")
|
||||
return response
|
||||
|
||||
@route("/static/400/<filename>", method="HEAD")
|
||||
def static_400(filename):
|
||||
template_path = abspath(getcwd()) / Path("tests/mock_server/templates")
|
||||
response = static_file(filename, root=template_path)
|
||||
response.status = 400
|
||||
response.add_header("Status-Code", "400")
|
||||
return response
|
||||
|
||||
@route("/static/400/<filename>", method="GET")
|
||||
def static_200(filename):
|
||||
template_path = abspath(getcwd()) / Path("tests/mock_server/templates")
|
||||
response = static_file(filename, root=template_path)
|
||||
response.add_header("Status-Code", "200")
|
||||
return response
|
||||
|
||||
@route("/redirect/headers/<filename>")
|
||||
def redirect_to_static(filename):
|
||||
redirect(f"/static/headers/$filename")
|
||||
|
||||
|
||||
def start():
|
||||
run(host='localhost', port=8080)
|
Loading…
Add table
Add a link
Reference in a new issue