(Aug-14-2020, 07:57 PM)t4keheart Wrote: Is something like this possible with python?
Of course this is possible,did't we answer this in the other thread?
The only way to learn this is to try stuff out,both Flask and Django comes build in web-server for local development this make it easy to start.
Quick demo that may help you get started,take first hit on Google about
html form,then send it to a Flask route instead to
/action_page.php
.
Folder/files
simple\
|-- app.py
templates\
|-- index.html
index.html
<!DOCTYPE html>
<html>
<body>
<h2>HTML Forms</h2>
<form action="/my_form" method="post">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
<p>If you click the "Submit" button, the form-data will be sent to a Flask route called my_form".</p>
</body>
</html>
app.py
from flask import Flask, request, render_template, url_for
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/my_form", methods=["POST"])
def bar():
f_name = request.form["fname"]
l_name = request.form["lname"]
full_name = f'<h2>First name: {f_name}<br>Last name: {l_name}</h2>'
return full_name
if __name__ == "__main__":
app.run(debug=True)
To run this,in folder of
simple
from command line.
G:\all_flask\2020\div\simple
λ python app.py
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Restarting with stat
* Debugger is active!
* Debugger PIN: 113-254-199
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
See that get a local host address,open that address in browser.
(Aug-14-2020, 08:44 PM)Axel_Erfurt Wrote: https://stackoverflow.com/questions/1596...hon-script
Not the best link Axel_Erfurt as it use CGI,this stuff is dead for Python web-development.
If fact the CGI module is deprecated in Python 3.8 and will be removed in 3.10.