This flask app checks a file for CRLF line endings.
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.
 
 
 
 

28 lines
617 B

from flask import Flask, render_template, request
app = Flask(__name__)
def check_if_crlf_in_stream(input) -> bool:
""" Check if any line in the input contains a CRLF character"""
for line in input:
if b"\r\n" in line:
return True
return False
@app.route("/")
def upload_file():
return render_template("upload.html")
@app.route("/uploader", methods=["POST"])
def check_file():
f = request.files["file"]
import pudb; pudb.set_trace()
check_if_crlf_in_stream(f.stream)
return render_template("result.html")
if __name__ == "__main__":
app.run(debug=True)