没事撸了个 api 的快速开发模板

2017 年 3 月 24 日
 xiaojieluo

连框架都算不上,就一个简单的目录结构,编程语言使用的是 python, 服务器用了 tornado, api 返回格式是 json

Github 地址: https://github.com/xiaojieluo/api_template

求 star...

安装

git clone https://github.com/xiaojieluo/api_template.git
pip install -r requirements.txt
python main.py

使用

默认端口是 8888 浏览器直接打开 localhost:8888/

2440 次点击
所在节点    程序员
8 条回复
Chichele
2017 年 3 月 24 日
我的天
renyijiu
2017 年 3 月 24 日
```python
#!/usr/bin/env python
# codin=utf-8
```

main.py 里这个没写错?
LeoQ
2017 年 3 月 24 日
@renyijiu 同意, python3 里已经不需要定义字符编码了
Kilerd
2017 年 3 月 24 日
不明其所述
mkstring
2017 年 3 月 24 日
好厉害哦!
KIDJourney
2017 年 3 月 24 日
#!/usr/bin/env python
# coding=utf-8

from api.handler.APIHandler import APIHandler

class index(APIHandler):
def get(self, username):
data = {
"name":username
}
self.write_json(data)


你在逗我?这算什么模板。
xiaojieluo
2017 年 3 月 24 日
@renyijiu 写快了漏掉了...
xiaojieluo
2017 年 3 月 24 日
@KIDJourney 这只是组织了一下目录结构啊,小玩意

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/349913

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX