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()
最新文章
- gong server
- LVS简介
- python 数据加密以及生成token和token验证
- 2016 CCPC 杭州站 小结
- (7)如何得到所有的 ";水仙花数"; ?
- /export/App/zz/phantomjs-1.9.7-linux-x86_64/bin
- cocos2dx 在windows上实现键盘输入
- android学习17——命令行建gradle工程
- 【转】 Python subprocess模块学习总结
- Django框架(二)
- Python3实战系列之七(获取印度售后数据项目)
- JAVA的初始化顺序:
- 十 suprocess模块
- am start的总结,-d参数的总结,以及python中传递内容包含中文及特殊字符&;的解决方案
- PHP 传值操作和传地址操作
- C#操作共享文件夹
- [GO]用go语言实现区块链工作原理
- 【WXS全局对象】Date
- java 搭建web项目
- project 的用法