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

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

  •  
  •   xiaojieluo · Mar 24, 2017 · 2362 views
    This topic created in 3337 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
        1
    Chichele  
       Mar 24, 2017
    我的天
    renyijiu
        2
    renyijiu  
       Mar 24, 2017
    ```python
    #!/usr/bin/env python
    # codin=utf-8
    ```

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