【问题标题】:tornado can't load jquery.js?龙卷风无法加载 jquery.js?
【发布时间】:2015-01-18 10:19:35
【问题描述】:

这是我的简单html,当我直接打开文件时,没有问题

<html>
<head>
    <meta charset="utf-8">a
    <title>Demo</title>
</head>
<body>
    <a href="http://jquery.com/">jQuery</a>
    <script src="jquery.js"></script>
    <script>

    $( document ).ready(function() {
        $( "a" ).click(function( event ) {
            alert( "The link will no longer take you to jquery.com" );
            event.preventDefault();
        });
    });

    </script>
</body>
</html>

但是,如果我输入 http://localhost:8000/tornaod 会给我WARNING:tornado.access:404 GET /jquery.js (::1) 3.00ms 的错误

以下是我的简单龙卷风代码...我不确定我的代码有什么问题...

class IndexHandler(tornado.web.RequestHandler):

    def get(self):
        self.render("./pages/index.html")


app = tornado.web.Application([(r'/test1', Test1Handler),
                            (r'/test2', Test2Handler),
                            (r'/test3', Test3Handler),
                            (r'/', IndexHandler)],
                            debug=True)
app.listen(options.port)
tornado.ioloop.IOLoop.instance().start()

【问题讨论】:

    标签: python tornado


    【解决方案1】:

    据我所知,您只指定了 4 个可通过 Tornado 访问的路径:/test1、/test2、test3 和 /。没有指定访问 /jquery.js 的路径。

    查看此问题以了解如何提供静态文件: Using Tornado, how do I serve static files and serve a favicon.ico from a different directory than the static path?

    【讨论】:

    • 与.html在同一文件夹级别的.js
    • @liuzhidong,对不起,没有看你的第一个描述。更新问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多