0

I am trying to load a text file in html using

<iframe src="TemperatureReadings.txt"></iframe>

it works perfectly when I run the html but when I run the html using flask it doesn't display anything any only an error message that I might have a bad URL.

So the question is: How am I able to display a textfile on my flask server since using iframe isn't working?

Håken Lid
  • 22,318
  • 9
  • 52
  • 67
Ryan
  • 3
  • 1
  • 7
  • The `src` for an iframe must point to a valid url. Something like `http://localhost:80/files/TemperatureReadings.txt` or wherever you serve that resource. The iframe can only access resources that can be fetched over http. It's not rendered server-side. – Håken Lid May 11 '17 at 18:35
  • So I cant just use the name of the text file even do its in the same directory as the HTML but I have to add "http://localhost:80/home/pi/Desktop/FlaskServer/templates/TemperatureReadings.txt" The full Directory basically + localhost.. ? @Håken Lid – Ryan May 11 '17 at 18:48
  • With an iframe, yes. You must provide a valid url that the client (web browser) can access. That's what iframes are for. If you want to render this server side, don't use an iframe. – Håken Lid May 11 '17 at 19:00

0 Answers0