Flask and Repl.it: personal page for each user

Ok. I like Flask. I want to use it on Internet. I want to use Python to make different pages for different users dependingo on their name.

I found this template on Repl.it and I made some changes to create a page with a different content for each user that can put their code to access to is. Pretty simple, very basic… but a start. If you do not know how flask works, read the blogs and watch the video in the links below.

Go to my template on Repl.it

What I changed in the template to fit my needs

I just put this dictionary that will contain the username/password (the key) and the persol content of the page (the value):

names = {
  "giovanni":
  """
Hai fatto tutti i compiti?

  """,
  
  "yahoo":
  "Tu hai fatto tutto"

}

with a couple of “codes” for two ipothetic users, just to test it.

Then I passed the variable to the template page in the render_template function.

	return render_template('personal_user.html', user=username,
  content=names[username])

And, then, I added this variable to the page (personal_user.html) that is in the templates folder.

 <span>{{content}}</span>.

The example in repl.it

 

 

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.