Replaced os.path in server.py

This commit is contained in:
Angel Rey 2020-09-30 14:05:39 -05:00 committed by Cristian Vargas
parent c35d5e6b41
commit 73418836f8

View file

@ -1,4 +1,3 @@
from os.path import abspath
from os import getcwd
from pathlib import Path
@ -10,20 +9,20 @@ def index():
@route("/static/<filename>")
def static_path(filename):
template_path = abspath(getcwd()) / Path("tests/mock_server/templates")
template_path = Path.cwd().resolve() / "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")
template_path = Path.cwd().resolve() / "tests/mock_server/templates"
response = static_file(filename, root=template_path)
response.set_header("Content-Type", "")
return response
@route("/static/headers/<filename>")
def static_path_with_headers(filename):
template_path = abspath(getcwd()) / Path("tests/mock_server/templates")
template_path = Path.cwd().resolve() / "tests/mock_server/templates"
response = static_file(filename, root=template_path)
response.add_header("Content-Language", "en")
response.add_header("Content-Script-Type", "text/javascript")
@ -32,7 +31,7 @@ def static_path_with_headers(filename):
@route("/static/400/<filename>", method="HEAD")
def static_400(filename):
template_path = abspath(getcwd()) / Path("tests/mock_server/templates")
template_path = Path.cwd().resolve() / "tests/mock_server/templates"
response = static_file(filename, root=template_path)
response.status = 400
response.add_header("Status-Code", "400")
@ -40,7 +39,7 @@ def static_400(filename):
@route("/static/400/<filename>", method="GET")
def static_200(filename):
template_path = abspath(getcwd()) / Path("tests/mock_server/templates")
template_path = Path.cwd().resolve() / "tests/mock_server/templates"
response = static_file(filename, root=template_path)
response.add_header("Status-Code", "200")
return response