Ask coding questions

← Back to all posts
How do I open a webpage? and have python communicate with that page?

Me and a friend( @TheC0derGirl ) are making a "simple" python game where you choose what to make: a pizza, icecream, and hot coco. And were going to open a page when its finished to show the finished product and we need to communacate those two projects to tell the website what the pizza or icecrem, etc. looks like so it knows what to put on the page.

Answered by 19ecal (228) [earned 5 cycles]
View Answer
19ecal (228)

You can send a link like this
and have a flask server at that address like

from flask import *
def main():
    if food=="pizza":
        return render_template("pizza.html")
    elif food=="icecream":
        return render_template("icecream.html")

You can have more URL arguments on the end like
Then have more elifs to render pizzawithcheese.html
And get the URL arguments with request.args.get

19ecal (228)

Sorry if that doesn't make as much sense as it could I'm on mobile and it's hard to type

TheC0derGirl (210)

@19ecal oooooooooooooooooooooooooooooh ok thanks


thanks! ill try and make sense of it!

19ecal (228)

@JULIODIAZ1 @TheC0derGirl I forgot, that won't work, you need to run it with"") at the end


question, would it be possible to send variables over from python to the html page? @19ecal

19ecal (228)

@JULIODIAZ1 Well, you can use this

from flask import *
def main():
    return render_template("page.html", text="some text")


        <p>{{ text }}</p>

That should put whatever you put text as in render_template() in the <p>


You can pass arguments as text (or http requests) or URL arguments to the website and receive it on the other end and show the image