Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

④全体 #12

Open
aokikousuke opened this issue Sep 15, 2018 · 12 comments
Open

④全体 #12

aokikousuke opened this issue Sep 15, 2018 · 12 comments
Labels

Comments

@aokikousuke
Copy link
Collaborator

aokikousuke commented Sep 15, 2018

#13
#14

@aokikousuke aokikousuke added the US label Sep 15, 2018
@sgnctct
Copy link
Collaborator

sgnctct commented Sep 15, 2018

@hiroakinet
Copy link
Collaborator

test1.html.zip
サンプルの画面です

@ghost
Copy link

ghost commented Sep 15, 2018

@ghost ghost closed this as completed Sep 15, 2018
@ghost ghost reopened this Sep 15, 2018
@sgnctct
Copy link
Collaborator

sgnctct commented Sep 15, 2018

csvの仕様
自分のデータファイル名:dengon00.csv
相手のデータファイル名:dengon99.csv

データフォーマット:
コード,No,時間,電番,名前,メッセージ,安否,場所
int,int,YYYYMMDDHHMMSS,0x000000000,string,string,int,int

安否リスト:
0:無事
1:軽傷
2:重症

場所リスト:
0:自宅
1:避難所
2:その他

@sgnctct
Copy link
Collaborator

sgnctct commented Sep 15, 2018

htmlの入力をcsv出力する
https://kikutoyo.net/blog/php_csv_output#PHP

@hiroakinet
Copy link
Collaborator

hiroakinet commented Sep 15, 2018

csvの仕様追加
・最新100件のみ使用する。(ファイルを削除するか、検索条件で100行のみにする)

@hiroakinet
Copy link
Collaborator

img_0481

@sgnctct
Copy link
Collaborator

sgnctct commented Sep 21, 2018

Webページ
dengon.zip

@sgnctct
Copy link
Collaborator

sgnctct commented Sep 21, 2018

参考情報:
①Pythonで遊ぼう 入力フォームのテキストを受け取って保存・表示
https://qiita.com/Gen6/items/52003d8c34a9c83a9964

②Pythonでcsvファイルに出力
https://qiita.com/a_t_a/items/50623aedf7e1dab3b876

③CGIで処理したデータをHTMLファイルに出力する方法
https://teratail.com/questions/95635

@sgnctct
Copy link
Collaborator

sgnctct commented Sep 22, 2018

pythonでhtmlのデータをcsvにするところがうまくいっていません。。


#!/usr/local/bin python
# -*- coding: utf-8 -*-
import sys, codecs
sys.stdout = codecs.getwriter("utf-8")(sys.stdout)
from datetime import datetime
import cgi
import csv

print "Content-Type: text/html\n"
print """

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
"""

print """
</head>
<body>
"""

try:
    form = cgi.FieldStorage()
    name = form["name"].value
    name = unicode(name,"utf-8")
    msn = form["msn"].value
    message = form["mess"].value
    message = unicode(message,"utf-8")
    safe = form["safe"].value
    light = form["light"].value
    unsafe = form["unsafe"].value
    home = form["home"].value
    shelter = form["shelter"].value
    etc = form["etc"].value
    today = datetime.now().strftime("%Y/%m/%d %H:%M:%S")
    f = open("dengon00.csv", "ab")
    writer = csv.writer(f, quoting=csv.QUOTE_ALL)
    writer.writerow([today,msn,name,message,safe,light,unsafe,home,shelter,etc])
    f.close()

    print "<p>"+ words + ": " + today + "</p>"

except (TypeError, KeyError):
    print "<p>"error"</p>"

print """
</body>
</html>
"""

@hiroakinet
Copy link
Collaborator

hiroakinet commented Sep 23, 2018

下記URLのようにpythonをcgiで動作できるように設定していますか?
https://qiita.com/aryoa/items/2c28b466e911a3dd101d

それと1行目
#!/usr/local/bin python
とありますが、
#!/urs/bin/python
としないと動作しません。
また、except行の下記は、

print "<p>"error"</p>"
→print "<p>error</p>"として下さい。

こちらでは
/home/pi/public_html
にdengon.html
/home/pi/public_html/cgi-bin/
に上記pythonのプログラムを入れて
http://localhost/~pi/dengon.html
で動作すると思いますが、こちらではまだerrorになってます・・・・

@hiroakinet
Copy link
Collaborator

hiroakinet commented Sep 24, 2018

伝言板のcsvファイルのサンプルデータを作成しましたので、追記や検索時のサンプルとして扱って下さい。
内容はそのままでもよいですが、メッセージ部分とかは適当に書き換えた方がよいかもしれません。

dengon.zip

プログラムで使いづらいようなら、フォーマット変更しますか?
日付(yyyy/mm/dd hh:mm:ss), 090xxxxxxxx, 名前、メッセージ、状態、避難場所
とかシンプルにしますか?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants