RaspberypiでガーデンIot その3 web環境の生成 cgiserver

・RaspberypiでガーデンIot その3 web環境の生成 cgiserver

import http.server
import sys
try:
  server_address = ("", 8000)
  handler_class = http.server.CGIHTTPRequestHandler #1 ハンドラを設定
  server = http.server.HTTPServer(server_address, handler_class)
  server.serve_forever()
except KeyboardInterrupt:
  sys.exit()  

・cgiserverの起動
sudo pyhton3 -m cgiserver.py

・cgiディレクトの作成 (cgiserverの規定値)
 /home/piの下にcgi-binを作成する

・sencer.htmlの作成

<html>
<head>
<title>Python3 CGI test1</title>
</head>
<body>
<h1>Python3 CGI sencer</h1><hr><p>
<form name = "Form1" method="POST" action="/cgi-bin/sencerdsp.py">
ymd: <input type="text" size=30 name="ymd"><p>
<input type="submit" value="送信" name="button1"><p>
</form>
</body>
</html>

・起動は
 http://localhost:8000/sencer.html
   ipアドレスでも可能
カテゴリー iot