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)
原文地址:https://www.cnblogs.com/panfengde/p/11231418.html
时间: 2024-10-08 02:31:53