Forums

Regarding webpage rendered in flask

Hello Team,

I am using flask in the backend. After user selects data and clicks submit, a bokeh plot file is embedded in output.html which is in /templates/ folder and the output.html is rendered. I am new to web development so my question is, what if multiple users concurrently try to access the app which is hosted on pythonanywhere? Will those two requests will be dealt separately? Since there is only one output.html in templates folder, won't it be corrupted if many users access the website simultaneously?

If you're using template files normally in Flask (that is, just with render_template, passing in context variables to provide the stuff that changes for each request) and you're not (say) writing to the template file from the code itself, then it will all be fine. Each time a request comes in, the template will be loaded into memory from the file, and then that copy in memory will have the context variables that you provided put into the appropriate places and the resulting page will be sent back to the browser. So Flask itself won't write to the template file on disk.