自己搭建Tornado
监听8000端口, 提供给小程序访问的地址为http://127.0.0.1:8000/index
#!/usr/bin/env python # -*- coding:utf-8 -*- import tornado.ioloop import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): print(‘GET方式请求成功‘) self.write("123") settings = { ‘template_path‘: ‘template‘, } application = tornado.web.Application([ (r"/index", MainHandler), ], **settings) if __name__ == "__main__": application.listen(8000) tornado.ioloop.IOLoop.instance().start()
微信页面js调用微信的API发送GET请求
Page({ onLoad:function(){ wx.request({ url: "http://127.0.0.1:8000/index", data:{ }, method:"GET", success:function(res){ console.log(res); } }) } })
执行结果:
时间: 2024-10-20 00:51:13