Wow look what i coded, and im 10 years old!

Sort:
Avatar of ItsWizriksChessmenber

from flask import Flask, render_template_string, request

app = Flask(__name__)

HTML_FORM = '''

<!doctype html>

<html>

<head>

    <title>Chess Info Form</title>

</head>

<body style="font-family: Arial; background-color: #f9f9f9; padding: 20px;">

    <h2>Tell us about you!</h2>

    <form method="post">

        <label>Chess.com username:</label><br>

        <input type="text" name="username" required><br><br>

        <label>Favorite color:</label><br>

        <input type="color" name="color"><br><br>

        <label>Do you like this website?</label><br>

        <input type="radio" name="like" value="Yes" required> Yes<br>

        <input type="radio" name="like" value="No"> No<br><br>

        <input type="submit" value="Submit">

    </form>

    {% if result %}

    <h3>Thanks for your input!</h3>

    <p><strong>Username:</strong> {{ result.username }}</p>

    <p><strong>Favorite Color:</strong> <span style="color: {{ result.color }}">{{ result.color }}</span></p>

    <p><strong>Likes Website:</strong> {{ result.like }}</p>

    {% endif %}

</body>

</html>

'''

@app.route("/", methods=["GET", "POST"])

def home():

    if request.method == "POST":

        result = {

            "username": request.form.get("username"),

            "color": request.form.get("color"),

            "like": request.form.get("like")

        }

        return render_template_string(HTML_FORM, result=result)

    return render_template_string(HTML_FORM, result=None)

Go to: Pythonaywere.com. create an acc, then go to New website, run this code

Avatar of ZackWillCheckU

amazing

Avatar of VietnamChessLovers_12

Cool

Avatar of ItsWizriksChessmenber

Thx guys

Avatar of ItsWizriksChessmenber

Bro stole my talk

Avatar of ItsWizriksChessmenber
MaestroDelAjedrez2025 escreveu:

Thanks guys

You

Avatar of TheEpicJellyfish
TheBestAllthewayrival wrote:

from flask import Flask, render_template_string, request

app = Flask(__name__)

HTML_FORM = '''

<!doctype html>

<html>

<head>

<title>Chess Info Form</title>

</head>

<body style="font-family: Arial; background-color: #f9f9f9; padding: 20px;">

<h2>Tell us about you!</h2>

<form method="post">

<label>Chess.com username:</label><br>

<input type="text" name="username" required><br><br>

<label>Favorite color:</label><br>

<input type="color" name="color"><br><br>

<label>Do you like this website?</label><br>

<input type="radio" name="like" value="Yes" required> Yes<br>

<input type="radio" name="like" value="No"> No<br><br>

<input type="submit" value="Submit">

</form>

{% if result %}

<h3>Thanks for your input!</h3>

<p><strong>Username:</strong> {{ result.username }}</p>

<p><strong>Favorite Color:</strong> <span style="color: {{ result.color }}">{{ result.color }}</span></p>

<p><strong>Likes Website:</strong> {{ result.like }}</p>

{% endif %}

</body>

</html>

'''

@app.route("/", methods=["GET", "POST"])

def home():

if request.method == "POST":

result = {

"username": request.form.get("username"),

"color": request.form.get("color"),

"like": request.form.get("like")

}

return render_template_string(HTML_FORM, result=result)

return render_template_string(HTML_FORM, result=None)

Go to: Pythonaywere.com. create an acc, then go to New website, run this code

Cool! *I am not understanding a letter of this*

Avatar of ItsWizriksChessmenber

Yes

Avatar of ItsWizriksChessmenber
epicsneyser3000 escreveu:
TheBestAllthewayrival wrote:

from flask import Flask, render_template_string, request

app = Flask(__name__)

HTML_FORM = '''

<!doctype html>

<html>

<head>

<title>Chess Info Form</title>

</head>

<body style="font-family: Arial; background-color: #f9f9f9; padding: 20px;">

<h2>Tell us about you!</h2>

<form method="post">

<label>Chess.com username:</label><br>

<input type="text" name="username" required><br><br>

<label>Favorite color:</label><br>

<input type="color" name="color"><br><br>

<label>Do you like this website?</label><br>

<input type="radio" name="like" value="Yes" required> Yes<br>

<input type="radio" name="like" value="No"> No<br><br>

<input type="submit" value="Submit">

</form>

{% if result %}

<h3>Thanks for your input!</h3>

<p><strong>Username:</strong> {{ result.username }}</p>

<p><strong>Favorite Color:</strong> <span style="color: {{ result.color }}">{{ result.color }}</span></p>

<p><strong>Likes Website:</strong> {{ result.like }}</p>

{% endif %}

</body>

</html>

'''

@app.route("/", methods=["GET", "POST"])

def home():

if request.method == "POST":

result = {

"username": request.form.get("username"),

"color": request.form.get("color"),

"like": request.form.get("like")

}

return render_template_string(HTML_FORM, result=result)

return render_template_string(HTML_FORM, result=None)

Go to: Pythonaywere.com. create an acc, then go to New website, run this code

Cool! *I am not understanding a letter of this*

Its called coding baibe

Avatar of SOUNDWAVE_SUPERIOR21

Is there a way to run this without an account?

Avatar of SOUNDWAVE_SUPERIOR21

Or another website?

Avatar of SOUNDWAVE_SUPERIOR21

They instructed to run it on pythonaywhere.com. Pythonaywhere.com requires an account to run code.

Avatar of ItsWizriksChessmenber
SOUNDWAVE_SUPERIOR21 escreveu:

Is there a way to run this without an account?

I dont think so

Avatar of ItsWizriksChessmenber

Yes its Pythonanywere.com

Avatar of ItsWizriksChessmenber

Im not on a school conp tho