You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
516 B

import difflib
def text_diff(text1, text2):
d = difflib.HtmlDiff()
html = d.make_table(text1.splitlines(), text2.splitlines(), context=True)
return html
def page():
from flask import render_template, request
diff_result = None
text1 = request.args.get("text1", "").strip()
text2 = request.args.get("text2", "").strip()
if text1 and text2:
diff_result = text_diff(text1, text2)
return render_template("text_diff.html", diff_result=diff_result, text1=text1, text2=text2)