'Making a python cybersecurty quiz

I'm currently making a python quiz while using flask.I made the radio button for only asking one question,but now I was thinking of importing a picture in q5,but whatever I try it doesn't work.I put my picture in the app directory/static/images.Do you have any suggestions? Thank you. This is my code now:

from pywebio.input import *
from pywebio.output import *
from flask import Flask
from pywebio.platform.flask import webio_view
from pywebio import STATIC_PATH
from pywebio.session import *

app = Flask(__name__)






def exam():
        
    c = 0
  
    put_html("<h1>Quiz</h1>")

    name = input("Please enter your name to start the test", type ="text", validate = validate_name)


    q1 = radio("Q1. What is phishing?",['scams through websites','scams through cryptocurrency','scams through emails',' scams through letters'])
    if q1 =='scams through emails':
        c+=1

    q2 = radio("Q2. Sara finds a message on her phone that she thinks might be a scam.  She should:",[" Forward the message to her friends to see if they think it's a scam too. ",'Reply and ask the sender not to send more mail.','Delete the message.'])
    if q2 =='Delete the message.':
        c+=1

    q3 = radio("Q3. What is the most common way to receive a phishing scam?",['Text message','Email','Downloading films','Unsafe wesbites'])
    if q3 =='Email':
        c+=1

    q4 = radio("Q4. Never give this out over the phone, through email or on the Internet.",['Personal Information','Free money','Baseball scores',"Tomorrow's lunch choices"])
    if q4 == 'Personal Information':
        c+=1

    q5 = radio("Q5. Is this a phishing scam?",['Yes','No'])
    if q5 == 'Yes':
        c+=1

    if c>3:
        message = [style(put_html("<h1 style='display:inline;border-bottom:0px'>Congratulations !! </h1>"+ name + ", your score is <b>"+ str(c) + "</b><br><br>") ,'color:green;'),style(put_html("<p>Result : <b>PASSED</b></p>"),'color:green'), put_html("<b>Thank You for your participation.</b>")]
        popup("Result", content=message, size='large', implicit_close=True, closable=True)
    else:
        message = [style(put_html("<h1 style='display:inline;border-bottom:0px'>Oops! " + "</h1>" + name + ", your score is <b>"+ str(c) + "</b><br><br>"),'color:red'), style(put_html("<p>Result : <b>FAILED</b></p>"), 'color:red') , put_html("<b>Thank You for your participation.</b><br><br>"), style(put_link('Retry ↺',""), 'color:red;align-content: center;border-radius: 5px;color:#f9faf8;padding: 5px 100px;text-align:center;align-items : center;background-color: white;\
            background-image: linear-gradient(270deg, #8cf5f5 1%, #0a43f3 100%);')]
        popup("Result", content=message, size='large', implicit_close=True, closable=True)
"""A method to validate the name entered by user"""
def validate_name(name):
    #removing all spaces from the input name
    name = name.replace(" ","")
    #performing validation checks
    #check 1 : Name must not be empty
    #check 2 : It should contain only alphabets [a-z] or [A-Z]
    if(name == "" or not(name.isalpha())):
        return("Please enter a non empty name consisting of alphabets only")



app.add_url_rule('/','webio_view',webio_view(exam),methods=['GET','POST','OPTIONS'])

if __name__ == '__main__':
    app.run(debug=True, port= 5000)

I did this,but this code below jst gave my an internall app error

q5 = radio("Q5. Is this a phishing scam?",image ="{{url_for('static',filename = 'images/q5.jpg')}}" >['Yes','No'])
    if q5 == 'Yes':
        c+=1


Solution 1:[1]

I just put before a line before q1 the following code:

put_image(  open(r"C:\Users\223\Desktop\phishing app\5.test\online-test-webapp-main\static\images\q4.png", 'rb').read(),  width='850px')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DenisDev