Hey i did a small project to display text on a web server but for some reason all the text is on the same line and i don't know how to change it.
code:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def main():
return """fxfxzvxczxcvxvzx
cxzvxczxcvcxvfdsvxz"""
if __name__ == "__main__":
app.run(debug=True, host="127.0.0.1", port=5050)
In your case you need to pass your output as html format to frontend; <br>
and </br>
are linebreaker tags in html;
Try this:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def main():
template = "fxfxzvxczxcvxvzx</br>cxzvxczxcvcxvfdsvxz"
return template
if __name__ == "__main__":
app.run(debug=True, host="127.0.0.1", port=5050)
Notes:
if you want to setup and export html format on larger scale you need to do it by flask template engine render or designer-friendly templating language like jinja just check these three links:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.