Bokeh嵌入了自定义.css和.js

问题描述 投票:2回答:1

我试图破解tornado embedded app example添加自定义css和js。我似乎无法正确联系css和js。我应该期望css和js文件在文档头中正常链接吗?

<head>
<link href="/static/css/custom.css" rel="stylesheet" type="text/css">
<script src="/static/js/custom.js"></script>
</head>

...或者我应该使用bokeh custom static handler首先加载所有内容?

...或者我可以将它传递给indexhandler类似:

class IndexHandler(RequestHandler):
    def get(self):
        template = env.get_template('embed.html')
        static = env.get_static('/css/style.css')
        script = server_document('default')
        self.write(template.render(script=script, template="Tornado", static=static))

以供参考:

app
|__data
|__static
|    |__css
|       |__custom.css
|    |__js
|       |__custom.js
|__templates
|    |__embed.html
|__main.py

只是寻找一些一般指导。谢谢。

python html css tornado bokeh
1个回答
0
投票

在调用extra_patterns时,你会向Server添加这样的东西:

(server_static_route, StaticFileHandler, { "path" : local_path_to_static_dir })

StaticFileHandler来自tornado.web

© www.soinside.com 2019 - 2024. All rights reserved.