Ok so like you have two popular alternatives: django and flask. But before you dive deep into python libraries convince yourelf that a large portion of front end talking to backend is a module known as an 'RESTful Application Programming Interface' or API. I promise all of this is way easier than it sounds. An rest api is just a module of code (flask,django,nodejs) that runs perpetually waiting for HTTP get and post requests. Just go through any basic youtube tutorial, there are thousands: and whenever you get stuck search for solutions on stackoverflow, if your problem has not been asked yet post a question yourself; most answers are given within like 6 hours. Sorry I know you know how stackoverflow works :'p Just don't be reluctant to post questions because you are bound to run into problems, a very popular one for example is that when returning a json object as a http response most learners do not add the "Access-Control-Allow-Origin" header which then blocks the client server communication across platforms in python-flask: res.headers.add('Access-Control-Allow-Origin':'*'); Also, an additional recommendation, before you upload your python code to heroku 1.make a 'requirements.txt' file in the directory you want to upload 2.open terminal and run the command 'pip freeze'. You'll get a list of all the libraries you have installed. Copy this list as it is and paste it in requirements.txt (if you're using Linux run the command 'pip freeze>requirements.txt') 3.install gunicorn by running command 'pip install gunicorn' 4.make another textfile name it procfile and put this code fragment in it 'web:gunicon :app' so if your code is in server.py 'web:gunicorn server:app' This is all info you will come across in your learning process anyways just giving a heads up. Happy coding :)) Answer from AccomplishedSet6407 on reddit.com
Reddit
reddit.com › r/learnprogramming › how do u connect front end (html) with back end ( python code)
r/learnprogramming on Reddit: How do u connect front end (html) with back end ( python code)
April 13, 2021 -
Can u help me guys , So i have an html file that has all the front end and another folder that has python codes( back end ) and i want to connect them together then deploy them to heroku . Do u guys know how do i do it?? Please i really need this for a school project
Top answer 1 of 7
6
Ok so like you have two popular alternatives: django and flask. But before you dive deep into python libraries convince yourelf that a large portion of front end talking to backend is a module known as an 'RESTful Application Programming Interface' or API. I promise all of this is way easier than it sounds. An rest api is just a module of code (flask,django,nodejs) that runs perpetually waiting for HTTP get and post requests. Just go through any basic youtube tutorial, there are thousands: and whenever you get stuck search for solutions on stackoverflow, if your problem has not been asked yet post a question yourself; most answers are given within like 6 hours. Sorry I know you know how stackoverflow works :'p Just don't be reluctant to post questions because you are bound to run into problems, a very popular one for example is that when returning a json object as a http response most learners do not add the "Access-Control-Allow-Origin" header which then blocks the client server communication across platforms in python-flask: res.headers.add('Access-Control-Allow-Origin':'*'); Also, an additional recommendation, before you upload your python code to heroku 1.make a 'requirements.txt' file in the directory you want to upload 2.open terminal and run the command 'pip freeze'. You'll get a list of all the libraries you have installed. Copy this list as it is and paste it in requirements.txt (if you're using Linux run the command 'pip freeze>requirements.txt') 3.install gunicorn by running command 'pip install gunicorn' 4.make another textfile name it procfile and put this code fragment in it 'web:gunicon :app' so if your code is in server.py 'web:gunicorn server:app' This is all info you will come across in your learning process anyways just giving a heads up. Happy coding :))
2 of 7
3
Maybe something like Flask? https://flask.palletsprojects.com/en/1.1.x/
How to connect my python back end to my HTML front end to create a GUI for Double hashing ? Any other means to create a GUI? - Stack Overflow
To connect front-end with backend using python you need a backend development framework. popular in python is Django full-stack, flask micro-framework, and pyramid full stack.. create web pages in HTML using all front end technology after that put all in 1 folder but anyway you need a framework for the link. You can use API also but ultimately need a FRAMEWORK. ... Find the answer to your question by asking... More on stackoverflow.com
How to run a Python script like a backend in HTML - Stack Overflow
I am trying to create a combo of ... lets users to scrape a particular website/s and display the information using requests module in python with the python script being executed from my server , in such a way that my webpage being the frontend and the python script being the backend · I tried using php with shell_exec function as shown in this ... More on stackoverflow.com
Tutorial: How to Combine Frontend and Backend (For Python Web Developers) - Show & Tell - Django Forum
For many Python web developers, how to make frontend and backend work together is a confusing issue. So I write this blog post to talk about the solutions. After reading, you will learn the six different ways to combine the frontend and backend, and the pros and cons. More on forum.djangoproject.com
How do u connect front end (html) with back end ( python code)
Ok so like you have two popular alternatives: django and flask. But before you dive deep into python libraries convince yourelf that a large portion of front end talking to backend is a module known as an 'RESTful Application Programming Interface' or API. I promise all of this is way easier than it sounds. An rest api is just a module of code (flask,django,nodejs) that runs perpetually waiting for HTTP get and post requests. Just go through any basic youtube tutorial, there are thousands: and whenever you get stuck search for solutions on stackoverflow, if your problem has not been asked yet post a question yourself; most answers are given within like 6 hours. Sorry I know you know how stackoverflow works :'p Just don't be reluctant to post questions because you are bound to run into problems, a very popular one for example is that when returning a json object as a http response most learners do not add the "Access-Control-Allow-Origin" header which then blocks the client server communication across platforms in python-flask: res.headers.add('Access-Control-Allow-Origin':'*'); Also, an additional recommendation, before you upload your python code to heroku 1.make a 'requirements.txt' file in the directory you want to upload 2.open terminal and run the command 'pip freeze'. You'll get a list of all the libraries you have installed. Copy this list as it is and paste it in requirements.txt (if you're using Linux run the command 'pip freeze>requirements.txt') 3.install gunicorn by running command 'pip install gunicorn' 4.make another textfile name it procfile and put this code fragment in it 'web:gunicon :app' so if your code is in server.py 'web:gunicorn server:app' This is all info you will come across in your learning process anyways just giving a heads up. Happy coding :)) More on reddit.com
Videos
10:37
How to Connect Python to HTML Easily | HTML with Python (2024) ...
05:13
Intro to FastHTML, the Python framework for frontend and backend ...
34:49
Part 1: Connect MySQL Database to Python Backend with ...
11:09
My First Web Application (Python, Django, HTML) - with Backend ...
DevOps.dev
blog.devops.dev › how-to-build-and-deploy-a-simple-frontend-app-with-python-backend-108b505be2be
How to Build and Deploy a Simple Frontend App with Python Backend | by krth1k | DevOps.dev
February 13, 2025 - app = Flask(__name__)@app.route('/api/message') def get_message(): return jsonify({"message": "Hello from the Python backend!"})if __name__ == '__main__': app.run(host='0.0.0.0', port=5000, debug=True) This API exposes a single endpoint /api/message that returns a JSON response. ... By default, it will run on http://127.0.0.1:5000/. For the frontend, we’ll use HTML, CSS, and JavaScript to display the data from our backend.
Stack Overflow
stackoverflow.com › questions › 56179495 › how-to-connect-my-python-back-end-to-my-html-front-end-to-create-a-gui-for-doubl
How to connect my python back end to my HTML front end to create a GUI for Double hashing ? Any other means to create a GUI? - Stack Overflow
To connect front-end with backend ... and pyramid full stack.. create web pages in HTML using all front end technology after that put all in 1 folder but anyway you need a framework for the link....
YouTube
youtube.com › watch
How to connect python backend to html front end - YouTube
Get Free GPT4o from https://codegive.com to connect a python backend to an html front end, you can use a web framework like flask or django in python to cre...
Published July 10, 2024
Top answer 1 of 3
2
Try using streamlit (https://streamlit.io)
code (app.py)
# import module
import streamlit as st
import requests
# Title
st.title("Running python from browser")
# Taking user input
user_input = st.text_input("Enter site to scrape")
# your script
if user_input:
r = requests.get(user_input)
st.write(r.status_code)
To deploy simply run
streamlit run app.py
2 of 3
1
There's a library called Brython (https://brython.info/), it can help you somewhat, but of course consider that there are limitations.
Here's the example of how to send request to HTTP site:
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/[email protected]/brython.min.js">
</script>
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/[email protected]/brython_stdlib.js">
</script>
</head>
<body onload="brython()">
<script type="text/python">
from browser import ajax
from browser import document
query = ''
url = 'http://www.http2demo.io/'
def get_request(url, q):
req = ajax.ajax()
req.bind('complete', on_complete)
req.open('GET', url+'?'+q, True)
req.set_header('content-type', 'application/x-www-form-urlencoded')
req.send()
def on_complete(r):
if r.status==200 or r.status==0:
document <= r.text
else:
document <= "error: " + r.text
get_request(url, query)
</script>
</body>
</html>
The better approach would be to create microservice, which would consist of front-end (user inputs URL to parse) and back-end (python logic - requests, etc.).
DataCamp
datacamp.com › tutorial › python-backend-development
Python Backend Development: A Complete Guide for Beginners | DataCamp
August 18, 2024 - However, Python can still play a role in full-stack development through templating engines like Jinja2 (used with Flask) or Django’s templating system, allowing you to generate HTML dynamically. Additionally, full-stack frameworks like Django come with tools for both backend and frontend development, such as form handling, URL routing, and template rendering, making Python a viable option for full-stack development.
freeCodeCamp
freecodecamp.org › news › backend-web-development-with-python-full-course
Backend Web Development with Python - Full Course
July 1, 2021 - Now you know we can add a single quotes in between our text does because Python is going to see this like we want to close on this prints text. So first we'll add the double quotes we can just easily add the bus slash then the quotes now once you have a blog slash, and that's good, this court is going to print it as I run it, you see now we have I with this good hour you so if you want to create special characters, we use the backslash, or you can just bring the backslash alone is gonna work.
freeCodeCamp
freecodecamp.org › news › pyscript-python-front-end-framework
How to Use PyScript – A Python Frontend Framework
May 12, 2025 - In this article, you learned what PyScript is all about and how to use it in HTML files to run Python code on the browser. You also learned about the various operations/functionalities you can do with PyScript. With PyScript, it’s easier to run and perform Python operations on the web, as this wasn’t easy before.
Real Python
realpython.com › html-css-python
HTML and CSS for Python Developers – Real Python
January 11, 2025 - Python can be used alongside HTML and CSS to create dynamic web content. HTML, CSS, and Python are sufficient for developing basic web applications. Learning HTML, CSS, and Python simultaneously is feasible and beneficial. Learning HTML and CSS first can give you a solid foundation before tackling Python. You can mix Python with HTML to automate and enhance web development.
Quora
quora.com › How-can-I-link-my-front-end-code-HTML-with-a-backend-Python-most
How to link my front-end code (HTML) with a backend (Python most) - Quora
You will need to call those python backend endpoints from your frontend application using javascript. The most basic idea of linking is to get data from the backend and populate it or send POST data to server.