37,737
社区成员
发帖
与我相关
我的任务
分享<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 101 Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link rel="stylesheet" href="{{ static_url("css/bootstrap.min.css") }}">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<form class="form-signin" role="form">
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" class="form-control" placeholder="Email address" required autofocus>
<input type="password" class="form-control" placeholder="Password" required>
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember me
</label>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
</div> <!-- /container -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="{{ static_url("js/jquery-2.2.0.min.js") }}"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="{{ static_url("js/bootstrap.min.js") }}"></script>
</body>
</html>import os.path
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
define("port", default=8010, help="run on the given port", type=int)
class LoginHandler(tornado.web.RequestHandler):
def get(self):
self.render('login.html')
class ShowHandler(tornado.web.RequestHandler):
def get(self):
self.render('login.html')
if __name__ == "__main__":
tornado.options.parse_command_line()
app = tornado.web.Application([(r"/login",LoginHandler),
(r"/test",ShowHandler)],
template_path = os.path.join(os.path.dirname(__file__),"templates"),
static_path =os.path.join(os.path.dirname(__file__), "static"),
debug = True
)
app1 = tornado.web.Application([(r"/login",LoginHandler),
(r"/test",ShowHandler)],
template_path = os.path.join(os.path.dirname(__file__),"templates"),
debug = True
)
app1.settings['static_path']=os.path.join(os.path.dirname(__file__), "static")
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start() app = tornado.web.Application([(r"/login",LoginHandler),
(r"/test",ShowHandler)],
template_path = os.path.join(os.path.dirname(__file__),"templates"),
static_path =os.path.join(os.path.dirname(__file__), "static"),
debug = True
)
app1 = tornado.web.Application([(r"/login",LoginHandler),
(r"/test",ShowHandler)],
template_path = os.path.join(os.path.dirname(__file__),"templates"),
debug = True
)
app1.settings['static_path']=os.path.join(os.path.dirname(__file__), "static")
http_server = tornado.httpserver.HTTPServer(app)>>> app.settings == app1.settings
True
[I 160216 19:24:47 web:1908] 304 GET /test (127.0.0.1) 23.42ms
[I 160216 19:24:47 web:1908] 304 GET /static/css/bootstrap.min.css?v=2f624089c65f12185e79925bc5a7fc42 (127.0.0.1) 10.48ms
[I 160216 19:24:47 web:1908] 304 GET /static/js/jquery-2.2.0.min.js?v=6fc159d00dc3cea4153c038739683f93 (127.0.0.1) 5.20ms[I 160216 19:25:52 web:1908] 304 GET /test (127.0.0.1) 22.28ms
[W 160216 19:25:52 web:1908] 404 GET /static/css/bootstrap.min.css?v=2f624089c65f12185e79925bc5a7fc42 (127.0.0.1) 8.89ms
[W 160216 19:25:52 web:1908] 404 GET /static/js/jquery-2.2.0.min.js?v=6fc159d00dc3cea4153c038739683f93 (127.0.0.1) 4.47ms
[W 160216 19:25:52 web:1908] 404 GET /static/js/bootstrap.min.js?v=c5b5b2fa19bd66ff23211d9f844e0131 (127.0.0.1) 4.85ms
if self.settings.get("static_path"):
path = self.settings["static_path"]
handlers = list(handlers or [])
static_url_prefix = settings.get("static_url_prefix",
"/static/")
static_handler_class = settings.get("static_handler_class",
StaticFileHandler)
static_handler_args = settings.get("static_handler_args", {})
static_handler_args['path'] = path
for pattern in [re.escape(static_url_prefix) + r"(.*)",
r"/(favicon\.ico)", r"/(robots\.txt)"]:
handlers.insert(0, (pattern, static_handler_class,
static_handler_args))