接口测试的知识点总结
283
2022-08-27
web.py
#-*- coding:utf-8 -*-import webimport jsonimport requests#from web.contrib.template import render_jinja#render=render_jinja('templates',encoding='utf-8')用jinja2渲染urls=( r'/index','Index', r'/search','Search')#db=web.database(dbn='mysql',host='',user='',pw='',port=,db='',charset-'utf8')#db.query|insert|update|deleterender=web.template.render('templates')#webpy自带的渲染def geturl(name): #request=requests.post(' try: result=requests.get(' result=json.loads(result.content.decode('utf-8')) if result.get('result'): return result['result']['songs'][0]['album']['picUrl'],result['result']['songs'][0]['audio'] else: return 'static/12.jpg','static/lizhi.mp3' except Exception as e: print e class Index(object): def GET(self): return render.a()class Search(object): def GET(self): text=web.input().get('search',None) imgurl,mp3url=geturl(text) return render.music(imgurl,mp3url) if __name__=='__main__': #print geturl('love') web.application(urls,globals()).run()#music.html
$def with(imgurl,mp3url,data)
$:a.title
--!>版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~