@app.route('/geo', methods=['GET', 'POST'])
def geo_web():
'''
RESTful API
given a piece of text, vectorize it, classify it into one of the regions using clf (a pre-trained classifier) and return a json which has info about the predicted location(s).
'''
text = request.args['text']
if isinstance(text, list) or isinstance(text, tuple) or len(text) == 0:
return
result = None
try:
result = geo(text, return_lbl_dist=False)
except:
return
return jsonify(**result)
如何将脚本输出写入文件,并构造一个web界面来使用这些文件并以只读模式显示它们?你知道吗
例如,在R中可以使用 接收器() 要将输出消息路由到一个文件,然后构造一个只显示此文件的web界面。你知道吗
在Python中,您可以很容易地使用Flask来提供restfulapi,客户机可以用它们的参数发送它们的HTTP请求,并且您可以向它们提供结果。你知道吗
将Python函数转换为web服务器非常容易。与此函数一样简单:
你只需要添加@应用程序路径... 并返回读取HTTP响应时可以处理的结果。你知道吗
你可以在here中看到我的整个项目。你知道吗
相关问题 更多 >
编程相关推荐