Forums

How to constantly print the output to a web page

When I start a loop to print the output of my code, I receive the following error:` Error running WSGI application

2020-01-14 03:18:24,663: BlockingIOError: [Errno 11] write could not complete without blocking
2020-01-14 03:18:24,663:   File "/var/www/blumushroom_pythonanywhere_com_wsgi.py", line 16, in <module>
2020-01-14 03:18:24,663:     from flask_app import app as application  # noqa
2020-01-14 03:18:24,663: 
2020-01-14 03:18:24,664:   File "/home/BluMushroom/mysite/flask_app.py", line 97, in <module>
2020-01-14 03:18:24,664:     start()
2020-01-14 03:18:24,664: 
2020-01-14 03:18:24,664:   File "/home/BluMushroom/mysite/flask_app.py", line 96, in start
2020-01-14 03:18:24,664:     letter()
2020-01-14 03:18:24,664: 
2020-01-14 03:18:24,664:   File "/home/BluMushroom/mysite/flask_app.py", line 82, in letter
2020-01-14 03:18:24,665:     print (number2,"                      ", number, "             ", number3)`

And I have no idea what I am doing wrong. Thanks in advance!

[edit by admin: formatting]

Prints do not go to the web page that is rendered on the browser. They go to the logging system and appear in your web app log files. If you're printing a lot and not returning a response, the system treats that as an error.

Do you know of any other way's I could do that?

When you say "constantly print the output to a web page", are you trying to write a site where someone visits a page, and it starts displaying data, adding more to the page over time? Or something else?

This blog post explains how to turn an existing Python script into a website, but it's designed very much for the kind of site where a visitor enters some values, clicks a button and gets an immediate response, so it might not be exactly what you're looking for it the above is the case.