我正在尝试准备默认错误页面。在SELECT ?p1 ?p1Label ?p1t1 ?p1t2 ?p2 ?p2Label ?p2t1 ?p2t2
WHERE {
FILTER (?p1=wd:Q935) . # Newton
?p1 wdt:P569 ?p1t1 . # date of birth
?p1 wdt:P570 ?p1t2 . # date of death
?p2 wdt:P106 wd:Q169470 . # physicist
?p2 wdt:P569 ?p2t1 . # date of birth
?p2 wdt:P570 ?p2t2 . # date of death
{ FILTER (xsd:dateTime(?p2t1) > xsd:dateTime(?p1t1))
. FILTER (xsd:dateTime(?p2t1) < xsd:dateTime(?p1t2)) }
UNION
{ FILTER (xsd:dateTime(?p2t2) > xsd:dateTime(?p1t1))
. FILTER (xsd:dateTime(?p2t2) < xsd:dateTime(?p1t2)) }
UNION
{ FILTER (xsd:dateTime(?p2t1) < xsd:dateTime(?p1t1))
. FILTER (xsd:dateTime(?p2t2) > xsd:dateTime(?p1t2)) } .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY xsd:dateTime(?p2t1)
文件中,我使用:
error.html
在龙卷风<link href="css/bootstrap.min.css" rel="stylesheet">
中,我使用以下路由指令:
Application
假设我输入(r'/css/(.*)', web.StaticFileHandler, {'path': 'assets/css'}
个网址。一切都很好,css文件正确加载,错误页面呈现正常。但是,当我键入http://localhost:8888/api
时,找不到css文件。
在第一种情况下,处理程序正确处理了css请求http://localhost:8888/api/foo
。在第二种方法中,对css的请求被转换为http://localhost:8888/css/bootstrap.min.css
,但未处理。
我希望在两种情况下都能找到资源以正确显示错误页面。我可以用:
http://localhost:8888/api/css/bootstrap.min.css
但是这次我可以输入浏览器(r'.*/css/(.*)', web.StaticFileHandler, {'path': 'assets/css'}
url并调出css文件,而我认为应该显示错误页面。我怎么能摆脱这个问题?
答案 0 :(得分:0)
这是因为你使用相对路径。有两种常见的解决方法:
使用绝对网址。在任何资源之前添加/
(斜杠),而不是<link href="css/bootstrap.min.css" rel="stylesheet">
使用<link href="/css/bootstrap.min.css" rel="stylesheet">
将<base>
添加到<head>
部分
Base ...指定用于文档中包含的所有相对URL的基本URL。
<base href="http://www.example.com/">
将处理程序保留为
(r'/css/(.*)', web.StaticFileHandler, {'path': 'assets/css'})
后者正在工作,因为它的正则表达式非常广泛,因为您注意到它处理应该是404
的请求。良好的做法是尽可能具有特定的路线。