?单个python文件即可快速搭建一个服务!以下分享模型代码及访问验证。
目录
# -*- coding: UTF-8 -*-
import json
import time
import datetime
import urllib, urllib2
import os, sys
from flask import Flask, jsonify, request
app = Flask(__name__)
MY_URL = '/api/py/'
@app.route(MY_URL + '/hhh', methods=['POST'])
def hh_svr():
param = request.json # 请求参数
input_data = param['data'] # str
# your biz
return jsonify({'code': 0, 'data': 'hh', 'msg': ""})
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=9010)
# app.run(debug=True)
curl http://127.0.0.1:9010/api/py/hhh -d " { \"data\": \"xxx\"}" -H "Content-Type: application/json" \ -X POST -v