Access the creat and del directories respectively.
#-*-Coding: UTF-8-*-import saeimport webimport xml. etree. elementTree as ETimport sae. constimport MySQLdbimport urllib2import jsonurls = ('/', 'Hello', '/creat', 'creatmenu ','/del ', 'deletemenu',) class Hello: def GET (self): data = web. input () echostr = data. echostr return echostr def POST (self): data = web. data () root = ET. fromstring (data) fromUser = root. findtext (". // FromUserName ") toUser = root. findtext (". // ToUserName ") CreateTime = root. findtext (". // CreateTime ") MsgType = root. findtext (". // MsgType ") Content = root. findtext (". // Content ") Content = Content. encode ('utf-8') db = MySQLdb. connect (host = sae. const. MYSQL_HOST, port = int (sae. const. MYSQL_PORT), user = sae. const. MYSQL_USER, passwd = sae. const. MYSQL_PASS, db = sae. const. MYSQL_DB, charset = 'utf8') c = db. cursor () SQL = "select * from py WHERE pro = '" + Content + "'" c.exe cute (SQL) rows = c. fetchone () tpl = '''
''' + FromUser + '''
''' + ToUser + '''
''' + CreateTime + '''
text
''' + Rows [2] + '''
'''Return tpl; # custom menu class creatmenu: def GET (self): appid = "wx7ced2a8593275753" secret = "71f475563d00103a356943875e96d43a" url = 'https: // logs? Grant_type = client_credential & appid = '+ appid +' & secret = '+ secret response = urllib2.urlopen (url) html = response. read () tokeninfo = json. loads (html) token = tokeninfo ['Access _ token'] post = ''' {"button": [{"type": "click", "name ": "Start", "key": "begin" },{ "type": "click", "name": "end", "key": "end "}, {"type": "click", "name": "game", "key": "play"}]} '''url = 'https: // api.weixin.qq.com/cgi-bin/menu/create? Access_token = '+ token req = urllib2.Request (url, post) response = urllib2.urlopen (req) return response # Delete menu class deletemenu: def GET (self ): appid = "wx7ced2a8593275753" secret = "71f475563d00103a356943875e96d43a" url = 'https: // api.weixin.qq.com/cgi-bin/token? Grant_type = client_credential & appid = '+ appid +' & secret = '+ secret response = urllib2.urlopen (url) html = response. read () tokeninfo = json. loads (html) token = tokeninfo ['Access _ token'] url = 'https: // api.weixin.qq.com/cgi-bin/menu/delete? Access_token = '+ token req = urllib2.Request (url) response = urllib2.urlopen (req) return responseapp = web. application (urls, globals ()). wsgifunc () application = sae. create_wsgi_app (app)