web.py实现jsonp

浏览器端请求

$.getJSON("/currenttime?callback=?",
   function (json){
      $("#time").html(json);
   }
); 

服务器端响应

class currenttime:
   def GET(self):
   web.header('Content-Type', 'application/javascript;charset=utf-8')
   callback = web.input(callback='callback')['callback']
   import time, json
   p=time.strftime("%S")+"℃"
   return "%s(%s)" %(callback,json.dumps(p)) 
原文地址:https://www.cnblogs.com/catmelo/p/4175280.html