美文网首页
🚇学python  2.0

🚇学python  2.0

作者: 飞过大西洋 | 来源:发表于2017-08-22 19:08 被阅读9次

    、、、

    import os

    from flask import Flask,jsonify

    import  json

    app = Flask(__name__)

    # Index / search

    @app.route('/', methods=['GET', 'POST'])

    def index():

      error = None

      if request.method == 'GET':

        data = None

      if request.method == 'POST':

        search_input = request.form['search']

        data = itunes_api.search_album(search_input, 'album', 100)

        if not data:

          error = 'No search results for ' + search_input

      return {'s':12}

    @app.route('/info')

    def show_info():

      data = {'a':1}

      return jsonify(data)

     

    if __name__ == "__main__":

      port = int(os.environ.get("PORT", 5000))

      app.run(host='0.0.0.0', port=port)

    、、、

    相关文章

      网友评论

          本文标题:🚇学python  2.0

          本文链接:https://www.haomeiwen.com/subject/zyaldxtx.html