如何使用锚标记在龙卷风中从一个html导航到另一个html

时间:2016-01-03 11:27:31

标签: python html tornado jinja2

大家好,这里是龙卷风中的一个小应用程序可以请你告诉我如何从一个html导航到其他 P.S现在我收到错误404未找到 我是否应该使用appengine或任何其他东西是必需的 提前谢谢

enter code here
 import tornado.httpserver
 import tornado.ioloop
 import tornado.options
 import tornado.web


 from tornado.options import define, options

 define("port", default=8888, help="run on the given port", type=int)


class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.render("template.html")
class indexhandler(tornado.web.RequestHandler):
    def get(self):
        self.render("index.html")



def main():
    tornado.options.parse_command_line()
    application = tornado.web.Application([
    ("/", MainHandler),
    ( "/index.html",indexhandler),
    ])
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.current().start()


if __name__ == "__main__":
main()

html第1页模板

<html>
<title>
basics
</title>
<head>
tornado
</head>
<body>
<h1> template</h1>
 <a href="index.html">goes to index.html </a> 
</body>
</html>

html -2 index.hmtl

enter code here
<html>
<head> index
</head>
<body>
<h2>2nd page in this application</h2>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

您发布的代码正在发挥作用。在新的virtualenv,最新的torando,同一目录中的所有文件:

kwarunek@home:/tmp$ virtualenv test
kwarunek@home:/tmp$ . test/bin/activate
(test)kwarunek@home:/tmp$ pip install tornado
(test)kwarunek@home:/tmp$ ls -l
-rw-rw-r--  1 kwarunek kwarunek  89 01-06 11:54 index.html
-rw-rw-r--  1 kwarunek kwarunek 768 01-06 11:53 server.py
-rw-rw-r--  1 kwarunek kwarunek 143 01-06 11:54 template.html
drwxrwxr-x  5 kwarunek kwarunek 120 01-06 11:50 test/

(test)kwarunek@home:/tmp$ python server.py
[I 160106 11:55:59 web:1946] 200 GET / (127.0.0.1) 6.88ms
[W 160106 11:55:59 web:1946] 404 GET /favicon.ico (127.0.0.1) 1.73ms
[W 160106 11:55:59 web:1946] 404 GET /favicon.ico (127.0.0.1) 1.40ms
[I 160106 11:56:06 web:1946] 200 GET /index.html (127.0.0.1) 2.28ms