Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1579

Python • Python / Flask server not displaying embedded text data on served out HTML file

$
0
0
Hello,

Let me preface this by saying that honestly, I am not sure if this is an HTML, python or Flask problem but I'm posting here since I think it might be either Flask or Python that is causing the issue.

I have an HTML file that displays perfectly when I open it directly as a file (it is actually HTML with embedded text from another file) but when getting it served out as a web page I only get the error:

"Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again."

My Python (with Flask) code is below

Code:

from flask import Flask, render_templateapp = Flask(__name__)@app.route('/')def home():    return render_template('index2.html')if __name__ == '__main__':    app.run(host="127.0.0.2", port=8080, debug=True)
I am using "127.0.0.2" rather than "127.0.0.1" since the latter is being used for a separate HTML file (both being served at the same time). But even stranger is that I've tested the above code using different HTML files and they all work fine which would indicate that the issue is with the HTML file / syntax but as mentioned, that displays perfectly when opening directly as a file.

And something else, I managed to get this embedded text data to appear days ago with the HTML file being served out but can't recall what HTML syntax I used, if that is even the problem.

If you can help, please let me know.

Statistics: Posted by Furutsu — Tue Nov 25, 2025 4:46 pm



Viewing all articles
Browse latest Browse all 1579

Trending Articles