def main(): print('Neo4j has connected...') form = KeywordSearchForm(request.form) try: if form.validate_on_submit(): print("Submit successfully...") keyword = form.keyword.data.strip() res = entity_analysis(keyword) try: if len(res) == 0: nothing = {'title': '<h1>Not Found</h1>'} return render_template('entity.html', nothing=json.dumps(nothing, ensure_ascii=False), form=form) else: res_json = raw2json.analysis(json.loads(json.dumps(res, ensure_ascii=False))) return render_template('entity.html', data=res_json['data'], links=res_json['links'], format_triple=res_json['format_triple'], categories=res_json['categories'], form=form) except: print("[log-neo4j] some error exist!!!") flash("some error exist!!!") else: flash("valid form") except: print("[log-neo4j] empty form") return render_template('entity.html', form=form)
def post(self): args = parser.parse_args() print('@', args) entity_json = raw2json.analysis( json.loads( json.dumps(entity_analysis(args['string']), ensure_ascii=False))) return entity_json
def get(self, string): # 根据string获取对应的value entity_json = raw2json.analysis(json.loads(json.dumps(entity_analysis(string), ensure_ascii=False))) return entity_json