Thanks stefano.menci. That helps some. I added a server call so that only admin can see the poll data.
sc549, I created the following users for both sites.
username: user@someemail.com
password: password
username: admin@someemail.com
password: password
I have created another site to experiment with doing everything that I want to keep private by utilizing server code. For the process of quiz creation, I have form that is only accessible by users that have admin privileges. In this form, I have a text box for quiz title and a text area for quiz questions and answers. This data is sent to the server which tries to write them to a text file using the info in this link (https://anvil.works/docs/media/files_on_disk.html). Below are some of the things that I have tried.
@anvil.server.callable
def writeQuizToFile(fileName, contents):
media_object = anvil.BlobMedia("text/plain", contents, name=fileName + ".txt")
with open(fileName + ".txt", "w+") as f:
f.write(media_object.get_bytes().decode())
@anvil.server.callable
def writeQuizToFile1(fileName, contents):
f = open("quizzes/" + fileName + ".txt", "w")
@anvil.server.callable
def read_a_media_object(fileName):
f = open("/dev/" + fileName + ".txt", "r")
return f.read()
I keep getting the following error.
FileNotFoundError: [Errno 2] No such file or directory: ‘chapter1Quiz.txt’
at ServerModule1, line 30
called from addQuiz, line 21