Skip to content
Sign upLog in
← Back to Community

Can you use Python with HTML?

Profile icon
CodersXD

In HTML, you can use javascript and CSS, but can you also use a python file and make it work in the program in any way?

Voters
Profile icon
TylerGoodwin1
Profile icon
CodersXD
Comments
hotnewtop
Profile icon
[deleted]

Yes you can! But I dont know how lol. I will try to find some tutorials

Profile icon
CodersXD
Profile icon
[deleted]

@CodersXD
Ok, use this code in the main.py file:

from flask import Flask, render_template app = Flask(__name__) @app.route('/') def index(): return render_template("index.html") app.run(host='0.0.0.0', port=8080)

And make a folder called templates, and put an index.html file in it. Put whatever you want in the html file, and there!

Profile icon
Coder100
Profile icon
Coder100

No, you can't. Python is backend, so python makes html and css work. Unless you are thinking of python on the browser...

Profile icon
CodersXD
Profile icon
Coder100

Python on the web

https://brython.info/

Enjoy!

Profile icon
RYANTADIPARTHI

I don't think you can use html, css, and js with python from the console. But you can with django - A web framework, or flask.

Here are some tutorials:

https://www.djangoproject.com/start/
https://flask.palletsprojects.com/en/1.1.x/tutorial/

Profile icon
CodersXD

@RYANTADIPARTHI
, I know what Django is, but I wanted to see if I can mix Python and HTML together to make something - A game, I know both can make a game, but both of them have strong points.