mirror of
https://github.com/pirate/ArchiveBox.git
synced 2025-08-10 16:46:40 +02:00
fix: Improve headers handling
This commit is contained in:
committed by
Cristian Vargas
parent
a40af98ced
commit
62ed11a5ca
@@ -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)
|
Reference in New Issue
Block a user