☆☆ 新着記事 ☆☆

2018年9月28日金曜日

Python3 基礎 html boiler template -cgi

/hello.py//
#!/usr/bin/python3
import cgi
print("Content-type:text/html\r\n\r\n")
print("<html><body>")
print("<h1>Hello Program!</h1>")
form = cgi.FieldStorage()
if form.getvalue("name"):
 name = form.getvalue("name")
 print("<h1>Hello "+name+"! Thanks for using my script!</h1><br />")
if form.getvalue("happy"):
 print("<p> Yay! I'm happy too! </p>")
if form.getvalue("sad"):
 print("<p> Oh no! Why are you sad? </p>")
print("<form method="post" action="hello.py">")
print("<p>Name: <input type="text" name="name"/></p>")
print("<input type="checkbox" name="happy" /> Happy")
print("<input type="checkbox" name="sad" /> Sad")
print("<input type="submit" value="Submit" />")
print("</form>")
print("</body></html>")

0 件のコメント:

コメントを投稿