Is there a way to implement Python in Web development the same way as PHP?

So my experience is with PHP and so far I have created a small little web program using PHP HTML CSS and JS(basic stuff). Well I started to use python because I’m extremely interested in Machine Learning and AI, so I created a simple Neural Network in Python using the sigmoid function. So I wanted to know if its possible to use python variables in html for things like inputs to pass them through the python code, then back out to show on the html web page.

Like I said I’m super new to python so I’m super extremely sorry if this is basic level stuff, but I’ve searching for a solution for hours online and cant fine anything.

Can someone point me in the right direction?

html & css are front-end, PHP & python are back-end. So either you need to let PHP and python communicate with each other, or write the back-end of your website in python (flask and django are options here).


As @stetim94 said, if you want to build a web application with Python you can use a framework such as Django or Flask.

Django is a framework built to get you up, coding and out to production in as swift a manner as possible. As a result, the Django devs have dealt with a lot of functionality for you already as part of Django - database abstraction, user authentication, session handling etc are all baked in to Django and you just need to leverage it through the framework.

Flask in comparison is a very small, lightweight framework. They provide the essential core services you need to run a web framework, and it’s up to you to either write the code or add in extensions to provide functionality you need.

I personally prefer Django, but that’s not to say that it’s better than Flask (or that Flask is better than Django). They both have their positives and negatives, and suit different purposes like most software.