settings = dict(
template_path=os.path.join(os.path.dirname(__file__),"blog/template"),
static_path=os.path.join(os.path.dirname(__file__),"static"),
static_url_prefix='/blog/'
)
application = web.Application( [
( r"/example", ExampleHandler ),
#( r"/other", OtherHandler ),
],**settings )
server = httpserver.HTTPServer(application)
server.listen(8888)
# server.start(num_processes=0)
tornado.ioloop.IOLoop.instance().start()
现在你可以你可以通过http://localhost:8888/blog/图片路径
图片需要存放在当前项目的static文件夹下也就是这句话的设置
static_path=os.path.join(os.path.dirname(__file__),"static")
这里我特意吧static_url_prefix 设置为 ‘/blog/’ 默认为’/static/’,你们也可以设置为你想要的前缀
static_url_prefix='/blog/'
你还可以这么设置
static_url_prefix='/blog/static/'