@@ -0,0 +1,1153 @@
+import tornado.httpserver%0Aimport tornado.ioloop%0Aimport tornado.options%0Aimport tornado.web%0Aimport hashlib%0A%0A%0Afrom tornado.options import define, options%0Adefine(%22port%22, default=80, help=%22run on the given port%22, type=int)%0A%0Aclass WeChatHandler(tornado.web.RequestHandler):%0A    def get(self):%0A        signature = self.get_argument('signature', 'none')%0A        timestamp = self.get_argument('timestamp', 'none')%0A        nonce = self.get_argument('nonce', 'none')%0A        echostr = self.get_argument('echostr', 'none')%0A        self.write(signature + %22 %22 + timestamp + %22 %22 + nonce + %22 %22 + echostr + %22 %22)%0A        token = %22nebula14%22%0A%0A        l = %5Btoken,timestamp,nonce%5D%0A        l.sort()%0A        sha1 = hashlib.sha1()%0A        map(sha1.update,l)%0A        hashcode = sha1.hexdigest()%0A         %0A %0A        if hashcode == signature:%0A            self.write(hashcode)%0A            #return echostr%0A%0Aif __name__ == %22__main__%22:%0A    tornado.options.parse_command_line()%0A    app = tornado.web.Application(handlers=%5B(r%22/wechat%22, WeChatHandler)%5D)%0A    http_server = tornado.httpserver.HTTPServer(app)%0A    http_server.listen(options.port)%0A    tornado.ioloop.IOLoop.instance().start()

hello.py