(Dec-10-2018, 08:11 PM)kunz Wrote: but this should use raw sockets in python making the input and output in a browser
For web-development raw sockect would be a nightmare to work with.
A short history
CGI was bad for Python regarding the future of web-development in Python,
and all Python solution's was work out WSGI(
PEP 3333).
Why is WSGI necessary?
So to day all web-framework is build on this standard eg Flask,Django...ect.
Example with
Flask.
form_test\
|-- app.py
templates\
|-- index.htm
app.py:
from flask import Flask, render_template, request, redirect, url_for
app = Flask(__name__)
@app.route('/')
def index():
return render_template("index.html")
@app.route('/text', methods=['GET', 'POST'])
def text(comments=[]):
if request.method == "GET":
return render_template("index.html", comments=comments)
value = request.form["text_input"]
comments.append(value[::-1] )
return redirect(url_for('text'))
if __name__ == '__main__':
app.run(debug=True)
index.html:
<!doctype html>
<html>
<head>
<title>Some title</title>
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='css/style1.css') }}" />
</head>
<body>
<h2>Form</h2>
<form action="/text" method="post">
Input text:<br>
<input type="text" name="text_input" value="">
<br>
<input type="submit" value="Submit">
</form>
<div id='foo'>
<br>
{% for comment in comments %}
<div class="row">
{{ comment }}
</div>
{% endfor %}
</div>
</body>
</html>