In php we use
<form autocomplete="off" method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<input type="text" name="text"/>
<input type="submit" />
$text = $_POST["text"] ;
$text = htmlspecialchars($text);
to display form data in browser.
but i want to do that same thing with pure python.
Is this possible?
You can't. You are talking about forms in a web browser. Browsers cannot interpret python language and the user interface where the forms are entered, are written in HTML.
Thus you do NEED to use a web framework.
Some resources where you find more detail. Django and Flask are both individual web frameworks for python.
The answer is to go through a web framework such as Django (as sugessted by most of the comments). Unfortunately you cannot use raw python code collect form data effectively. Thes the backend (like php) it is stored on the server. Django is very useful for projects like blogs, web apps, ect. Although I don't recommend starting to learn the Django library yourself because in itself it can be kind of confusing (based of of personal experience). If you want to implement the python into web development, I recommend going through a tutorial on the Django framework, such as this one:
Hope this helps
An actual programming-related question, hallelujah! :)
Your title suggests something else though, one of the many, many unanswerable questions like 'Which is better, Python or PHP?'
So in order to get seen, you might want to change your title to something more specific.
You will have to use a framework.
Cherrypy is a lightweight framework. It is as easy as.
pip install CherryPy
class HelloWorld(object): @cherrypy.expose
return "Hello World!"