Replaced os.path in server.py
This commit is contained in:
parent
c35d5e6b41
commit
73418836f8
1 changed files with 5 additions and 6 deletions
|
@ -1,4 +1,3 @@
|
||||||
from os.path import abspath
|
|
||||||
from os import getcwd
|
from os import getcwd
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -10,20 +9,20 @@ def index():
|
||||||
|
|
||||||
@route("/static/<filename>")
|
@route("/static/<filename>")
|
||||||
def static_path(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)
|
response = static_file(filename, root=template_path)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@route("/static_no_content_type/<filename>")
|
@route("/static_no_content_type/<filename>")
|
||||||
def 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 = static_file(filename, root=template_path)
|
||||||
response.set_header("Content-Type", "")
|
response.set_header("Content-Type", "")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@route("/static/headers/<filename>")
|
@route("/static/headers/<filename>")
|
||||||
def static_path_with_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 = static_file(filename, root=template_path)
|
||||||
response.add_header("Content-Language", "en")
|
response.add_header("Content-Language", "en")
|
||||||
response.add_header("Content-Script-Type", "text/javascript")
|
response.add_header("Content-Script-Type", "text/javascript")
|
||||||
|
@ -32,7 +31,7 @@ def static_path_with_headers(filename):
|
||||||
|
|
||||||
@route("/static/400/<filename>", method="HEAD")
|
@route("/static/400/<filename>", method="HEAD")
|
||||||
def static_400(filename):
|
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 = static_file(filename, root=template_path)
|
||||||
response.status = 400
|
response.status = 400
|
||||||
response.add_header("Status-Code", "400")
|
response.add_header("Status-Code", "400")
|
||||||
|
@ -40,7 +39,7 @@ def static_400(filename):
|
||||||
|
|
||||||
@route("/static/400/<filename>", method="GET")
|
@route("/static/400/<filename>", method="GET")
|
||||||
def static_200(filename):
|
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 = static_file(filename, root=template_path)
|
||||||
response.add_header("Status-Code", "200")
|
response.add_header("Status-Code", "200")
|
||||||
return response
|
return response
|
||||||
|
|
Loading…
Reference in a new issue