码迷,mamicode.com
首页 > 其他好文 > 详细

flask使用模板

时间:2019-07-23 14:52:15      阅读:56      评论:0      收藏:0      [点我收藏+]

标签:import   file   local   ict   bug   %s   main   index   run   

flask常用代码模板

from flask import Flask, request
import requests

app = Flask(__name__)


@app.route('/')
def index():
    return '<h1>test</h1>'


@app.route('/user/<username>')
def show_user_profile(username):
    # show the user profile for that user
    return 'User %s' % username


@app.route('/go', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        username = request.form['name']
        result = aad()
        return result
    else:
        return 'get'


def aad():
    que = [1, 2, 3, 44, 5, 6, 7, 8] + [0] * 348
    input = [que]
    # print(input)
    url = 'http://localhost:8501/v1/models/aad_serve:predict'
    response = requests.post(url, json={"instances": input})
    # print(response.text)
    return (response.text)


if __name__ == '__main__':
    app.run(debug=True, port=8777)

flask使用模板

标签:import   file   local   ict   bug   %s   main   index   run   

原文地址:https://www.cnblogs.com/panfengde/p/11231418.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!