ArchiveBox/tests/mock_server/server.py

25 lines
705 B
Python
Raw Normal View History

from os.path import abspath
from os import getcwd
from pathlib import Path
from bottle import route, run, static_file
@route("/")
def index():
return "Hello"
@route("/static/<filename>")
def static_path(filename):
2020-09-23 15:34:05 +00:00
template_path = abspath(getcwd()) / Path("tests/mock_server/templates")
response = static_file(filename, root=template_path)
return response
@route("/static_no_content_type/<filename>")
def static_no_content_type(filename):
template_path = abspath(getcwd()) / Path("tests/mock_server/templates")
response = static_file(filename, root=template_path)
response.set_header("Content-Type", "")
return response
def start():
run(host='localhost', port=8080)