WebServer_简单例子


#-*-coding:utf-8-*-

importweb
importjson

urls=("/.*","index")
app=web.application(urls,globals())

classindex:
"""
Server:Apache-Coyote/1.1
Pragram:no-cache
Cache-Control:no-cache,no-store,max-age=0
Expires:Thu,01Jan197000:00:00GMT
Content-Type:application/json;charset=UTF-8
Content-Language:zh-CN
Transfer-Encoding:chunked
"""
defGET(self):
res='你好中国'
#a=res.decode('utf8')
#b=a.encode('gb2312')
web.header('content-type','application/json;chartset=UTF-8')
returnres


defPOST(self):
web.header('content-type','application/json;chartset=UTF-8')
web.header('Server','Webpy')
web.header('Content-Language','zh-CN')
web.header('Pragram','no-cache')
web.header('Cache-Control','no-cache,no-store,max-age=0')

#res={
#"code":0,
#"msg":"success",
#"data":{"table":[{"id":"1","name":"世界上最美的花","fileUrl":"/home/STE-test/Testdata/世界上最美的花.mp3"},
#{"id":"5","name":"夏洛特烦恼","fileUrl":"/home/STE-test/Testdata/夏洛特烦恼.mp3"}
#]
#}
#}
res={"code":0,"msg":"success","data":{"isPlay":1,"duration":3589,"totalTime":3600}}
j_res=json.dumps(res)

returnj_res


if__name__=="__main__":
app.run()

优质内容筛选与推荐>>
1、Android全屏的两种方法
2、rem
3、hive 学习系列一(数据类型的定义)
4、ionic启动App时不使用淡入淡出效果
5、论电子病历文本编辑器


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号