1
ccdjh 2012-12-14 16:34:28 +08:00
1是直接写进参数里面
2是直接获取。 |
2
kenneth OP @ccdjh 能否解释下,比如/?tagname=美女,我可以通过get_argument得到,但是/美女。我如何得到这个参数?
|
3
ipconfiger 2012-12-14 16:42:16 +08:00
class MeiNvHandler(tornado.web.RequestHandler):
def get(self,tagname): #do sth |
4
zeyexe 2012-12-14 16:43:00 +08:00 1
(r'/tag/(.*)', TagHandler),
class TagHandler(BaseHandler): def get(self, *args): self.write("Hello," + args[0]) 这样应该可以 |
5
kenneth OP @ipconfiger tagname这个变量是对应我数据库的字段名?需要对应什么?
|
6
ccdjh 2012-12-14 16:59:42 +08:00
#!/usr/bin/env python
# coding=utf-8 import os import tornado.wsgi import tornado.web import sae class ArticleHandler(tornado.web.RequestHandler): def get(self): c = self.get_argument('id') self.write(c) class TagHandler(tornado.web.RequestHandler): def get(self,tag): self.write(tag) app = tornado.wsgi.WSGIApplication([ (r"/article/", ArticleHandler), (r"/tag/([0-9a-zA-Z\-\_]+)", TagHandler), ]) application = sae.create_wsgi_app(app) |
7
ipconfiger 2012-12-14 17:00:46 +08:00
|
8
kenneth OP |