linked2 = re.sub(r'\[\[([^\]]+)\]\]', r'<a href="%s">\1</a>' % url2, linked1, count=1) edge['linked'] = linked2 out_edges.append(edge) seen_edges[edge['uri']] = edge else: oldedge = seen_edges[edge['uri']] oldedge['score'] += edge['score'] if not oldedge.get('linked'): text = edge.get('surfaceText') or '' url1 = WEB_ROOT+edge['start'] url2 = WEB_ROOT+edge['end'] linked1 = re.sub(r'\[\[([^\]]+)\]\]', r'<a href="%s">\1</a>' % url1, text, count=1) linked2 = re.sub(r'\[\[([^\]]+)\]\]', r'<a href="%s">\1</a>' % url2, linked1, count=1) oldedge['linked'] = linked2 if not edges: return render_template('not_found.html', uri=uri, languages=LANGUAGES) else: return render_template('edges.html', uri=uri, caption=caption, edges=out_edges, root=WEB_ROOT, languages=LANGUAGES) @app.errorhandler(404) def handler404(error): return render_template('404.html', languages=LANGUAGES), 404 if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=8080)
from conceptnet5.api import app if __name__ == '__main__': app.debug = True app.run('0.0.0.0', debug=True, port=10052)
url1 = WEB_ROOT + edge['start'] url2 = WEB_ROOT + edge['end'] linked1 = re.sub(r'\[\[([^\]]+)\]\]', r'<a href="%s">\1</a>' % url1, text, count=1) linked2 = re.sub(r'\[\[([^\]]+)\]\]', r'<a href="%s">\1</a>' % url2, linked1, count=1) oldedge['linked'] = linked2 if not edges: return render_template('not_found.html', uri=uri, languages=LANGUAGES) else: return render_template('edges.html', uri=uri, caption=caption, edges=out_edges, root=WEB_ROOT, languages=LANGUAGES) @app.errorhandler(404) def handler404(error): return render_template('404.html', languages=LANGUAGES), 404 if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=8080)