• 请不要在回答技术问题时复制粘贴 AI 生成的内容
xiaojieluo
V2EX  ›  程序员

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

  •  
  •   xiaojieluo · Mar 24, 2017 · 2611 views
    This topic created in 3519 days ago, the information mentioned may be changed or developed.

    连框架都算不上,就一个简单的目录结构,编程语言使用的是 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/

    Chichele
    Chichele
    Mar 24, 2017
    1
    我的天
    renyijiu
    renyijiu
    Mar 24, 2017
    2
    ```python
    #!/usr/bin/env python
    # codin=utf-8
    ```

    main.py 里这个没写错?
    LeoQ
    LeoQ
    Mar 24, 2017 via iPhone
    3
    @renyijiu 同意, python3 里已经不需要定义字符编码了
    Kilerd
    Kilerd
    Mar 24, 2017
    4
    不明其所述
    mkstring
    mkstring
    Mar 24, 2017
    5
    好厉害哦!
    KIDJourney
    KIDJourney
    Mar 24, 2017
    6
    #!/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
    xiaojieluo
    OP
    Mar 24, 2017
    7
    @renyijiu 写快了漏掉了...
    xiaojieluo
    xiaojieluo
    OP
    Mar 24, 2017
    8
    @KIDJourney 这只是组织了一下目录结构啊,小玩意
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   906 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 21:18 · PVG 05:18 · LAX 13:18 · JFK 16:18
    ♥ Do have faith in what you're doing.