Search code examples
pythontornado

tornado can't load jquery.js?


here is my simple html, when I open the file directly, there is no issue

<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>

However, if i input the http://localhost:8000/ tornaod gives me the error that WARNING:tornado.access:404 GET /jquery.js (::1) 3.00ms

following is my simple tornado code...I am not sure what wrong with my code...

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()

Solution

  • From what I see, you have only 4 paths specified to be accessible via Tornado: /test1, /test2, test3 and /. There is no path specified to access /jquery.js.

    Theck this question to see how to serve static files: Using Tornado, how do I serve static files and serve a favicon.ico from a different directory than the static path?