Output a file from a flask

Asked 2 years ago, Updated 2 years ago, 117 views

I'm developing a flask web. When the user uploads the file via the web, process it and save it as a file. You are about to print this file out over the web. Originally, I read the file and printed it out, and they removed all the line changes and tabs and sent it. So I'm looking for a way to transfer the file itself to HTML. Or is there a way to take the line change and tab as it is when reading the file?

flask

2022-09-22 19:11

1 Answers

If you want to implement a line change or tab of a plain text file in HTML, you can create a simple function in JavaScript and implement it. In plain text, line breaks are usually expressed as \n, so you can create a simple function that replaces them with <br> tags.

function nl2br(str){  
    return str.replace(/\n/g, "<br>");  
} 


2022-09-22 19:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.