From bda10ea10516f5ea1cf9f93472fc1f2ba2e89762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Mon, 3 Jun 2019 10:29:37 +0900 Subject: [PATCH] Add: test codes for sending data from python to javascript (failed) --- src/web/client/test_python.html | 70 +++++++++++++++++++ .../python/chocomae/test_send_json_data.py | 22 ++++++ 2 files changed, 92 insertions(+) create mode 100644 src/web/client/test_python.html create mode 100644 src/web/python/chocomae/test_send_json_data.py diff --git a/src/web/client/test_python.html b/src/web/client/test_python.html new file mode 100644 index 0000000..cabbb86 --- /dev/null +++ b/src/web/client/test_python.html @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + +

Data

+
+ + \ No newline at end of file diff --git a/src/web/python/chocomae/test_send_json_data.py b/src/web/python/chocomae/test_send_json_data.py new file mode 100644 index 0000000..d178420 --- /dev/null +++ b/src/web/python/chocomae/test_send_json_data.py @@ -0,0 +1,22 @@ +import CGIHTTPServer +import cgi +import os +print "Content-type: text/html" +print + +dir = os.path.dirname(os.path.realpath(__file__)) +form = cgi.FieldStorage() + +word = form["name"].value.upper() +word_len = len(word) +lines = open(dir+"\names.txt", "r").readlines() +names = [line.split()[0] for line in lines] +names.sort() + +names_to_return = [] + +for name in names: + if name[:word_len]==word: + names_to_return.append(name) + +print ', '.join(names_to_return) \ No newline at end of file