您的位置:首页 > 编程语言 > Python开发

Python基础-项目实战-day8新增API

2018-01-08 10:50 661 查看

一、新增API

MVC架构中在handls.py新增

@get('/api/users')
def api_get_users():
users = yield from User.findAll(orderBy='created_at desc')
for u in users:
u.passwd = '******'
return dict(users=users


上述可以再浏览器中输入

http://127.0.0.1:9000/api/users

二、运行结果

1.从数据库读取数据



2.浏览器http://127.0.0.1:9000/api/users



三、具体Python实战-廖雪峰

https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014323391480651a75b5fda4cb4c789208191682fc2c70000

四、Git提交

https://github.com/sufadi/python3-webapp-Su/blob/master/www/handlers.py

git add www/
git commit -m "新增一个API"
git push -u origin master
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  新增API 项目实战