🔨」 fix: fixed post request with cgi

This commit is contained in:
2025-05-30 16:17:21 +02:00
parent 64764d18c4
commit 30866645a0
11 changed files with 80 additions and 37 deletions

30
exemples/webpage/post_cgi.py Executable file
View File

@ -0,0 +1,30 @@
#!/nix/store/kjvgj2n3yn70hmjifg6y0bk9m4rf7jba-python3-3.12.10/bin/python3
import cgi
import cgitb
# Enable error reporting
cgitb.enable()
print("Content-Type: text/html") # HTML is following
print() # blank line, end of headers
form = cgi.FieldStorage()
# Get data from fields
name = form.getvalue("name")
email = form.getvalue("email")
print(f"""
<!DOCTYPE html>
<html>
<head>
<title>POST Request Received</title>
</head>
<body>
<h1>POST Request Received</h1>
<p>Name: {name}</p>
<p>Email: {email}</p>
</body>
</html>
""")