#1
by
Juliana
Hi, I have an app that is working fine locally. But when I run it through Heroku, I get the error in attachment. How can I fix this? Thank you!
#2
by
Juliana
And here is my code in the init file
class quiz(Page):
form_model = 'player'
form_fields = ['quiz_answer']
timeout_seconds = 30
@staticmethod
def vars_for_template(player: Player):
participant = player.participant
image = participant.images[player.round_number - 1]
num = ""
for c in image:
if c.isdigit():
num = num + c
player.quiz_question = num
return {'img_to_show': "{}".format(image)}
#3
by
Chris_oTree
Check whether the file extension is .png or .PNG. Heroku servers are unix-based and therefore case sensitive.
#4
by
Juliana
Thanks Chris. Now, all my images are .png (and so it is specified in the file path), but I get the same error (see in attachment). Any other ideas for why this could be happening? Again, I have no issue locally on my computer.
def creating_session(subsession: Subsession):
PicturePool = [i.split("/")[-1] for i in glob('_static/questions/*png')]
if subsession.round_number == 1:
for p in subsession.get_players():
selected_img = random.sample(PicturePool, k=30)
PicturePool = [e for e in PicturePool if e not in selected_img]
print('player', p.id_in_subsession)
print(selected_img)
print(len(PicturePool))
p.participant.images = selected_img
class quiz(Page):
form_model = 'player'
form_fields = ['quiz_answer']
timeout_seconds = 30
@staticmethod
def vars_for_template(player: Player):
participant = player.participant
image = participant.images[player.round_number - 1]
num = ""
for c in image:
if c.isdigit():
num = num + c
player.quiz_question = num
return {'img_to_show': "{}".format(image)}
#5
by
Juliana
Thanks Chris. Now, all my images are .png (and so it is specified in the file path), but I get the same error (see in attachment). Any other ideas for why this could be happening? Again, I have no issue locally on my computer.
def creating_session(subsession: Subsession):
PicturePool = [i.split("/")[-1] for i in glob('_static/questions/*png')]
if subsession.round_number == 1:
for p in subsession.get_players():
selected_img = random.sample(PicturePool, k=30)
PicturePool = [e for e in PicturePool if e not in selected_img]
print('player', p.id_in_subsession)
print(selected_img)
print(len(PicturePool))
p.participant.images = selected_img
class quiz(Page):
form_model = 'player'
form_fields = ['quiz_answer']
timeout_seconds = 30
@staticmethod
def vars_for_template(player: Player):
participant = player.participant
image = participant.images[player.round_number - 1]
num = ""
for c in image:
if c.isdigit():
num = num + c
player.quiz_question = num
return {'img_to_show': "{}".format(image)}
#6
by
Juliana
Thanks Chris. Now, all my images are .png (and so it is specified in the file path), but I get the same error (see in attachment). Any other ideas for why this could be happening? Again, I have no issue locally on my computer.
def creating_session(subsession: Subsession):
PicturePool = [i.split("/")[-1] for i in glob('_static/questions/*png')]
if subsession.round_number == 1:
for p in subsession.get_players():
selected_img = random.sample(PicturePool, k=30)
PicturePool = [e for e in PicturePool if e not in selected_img]
print('player', p.id_in_subsession)
print(selected_img)
print(len(PicturePool))
p.participant.images = selected_img
class quiz(Page):
form_model = 'player'
form_fields = ['quiz_answer']
timeout_seconds = 30
@staticmethod
def vars_for_template(player: Player):
participant = player.participant
image = participant.images[player.round_number - 1]
num = ""
for c in image:
if c.isdigit():
num = num + c
player.quiz_question = num
return {'img_to_show': "{}".format(image)}