def get(self): self.add_header('content-type', 'image/gif') img, img_str = create_validate_code() img.save(pathjoin('common', 'validate', 'captcha.gif')) self.set_secure_cookie('imgcaptcha', img_str) with open(pathjoin('common', 'validate', 'captcha.gif'), 'rb') as f: self.write(f.read())
from forward.httpbase import HttpBaseHandler from forward.modules.mt.goods.db_goods import * from forward.modules.mt.settings import * from forward.common.tools import tornado_argument, tornado_argument_json from forward.modules.mt.merchant.handlers_merchant import desc_fansmessageconfig_mass from forward.db.tables_define import FD_T_Fansmessage from tornado.httpclient import AsyncHTTPClient from tornado.httpclient import HTTPRequest from forward.common.tools import pathjoin from tornado.template import Loader from forward.common.trans import * from forward.common import trans from forward.config import CONFIG loader = Loader(pathjoin("modules", "mt", "goods")) class GoodsCategoryHandler(HttpBaseHandler): def get(self, category_id): response = get_goodscategory(category_id) self.write(response) class GoodsHandler(HttpBaseHandler): @tornado_argument('_shop_id', '_offset', '_limit', '_status') def get(self): """ get goods, status could be -2~2, or multipuls with dot like 1,2 """ status = trans.to_list(self.arg.status)