commit 4940f970795c86f4923db26a6347f8ddae6ab32c
parent c06ecf1c709029c1bb2c5b19c32e6eb2b823d5f0
Author: Joris Vink <joris@coders.se>
Date: Thu, 26 Jan 2017 22:01:23 +0100
remove stuff that is not ready yet and add README.
Diffstat:
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/examples/python/README.md b/examples/python/README.md
@@ -0,0 +1,14 @@
+Kore python module example.
+
+Run:
+```
+ $ kore run
+```
+
+Test:
+```
+ $ curl -k https://127.0.0.1:8888
+ $ curl -k https://127.0.0.1:8888/state
+ $ curl -k https://127.0.0.1:8888/auth
+ $ curl -X PUT -d '{\"hello\": 123}' https://127.0.0.1/json
+```
diff --git a/examples/python/src/index.py b/examples/python/src/index.py
@@ -11,15 +11,6 @@ def python_validator(req, data):
print("python validator called %s" % data)
return kore.RESULT_OK
-def python_handle(c):
- print("python_handle %s" % c)
-
-def python_on_connect(c):
- c.proto = kore.CONN_PROTO_UNKNOWN;
- c.state = kore.CONN_STATE_ESTABLISHED;
- c.handle = python_handle
- print("onconnect %s" % c)
-
def onload(action):
kore.log(kore.LOG_INFO, "FOOBAR python onload called with %d" % action)
return kore.RESULT_OK
@@ -31,11 +22,11 @@ def kore_preload():
print("kore_preload called")
def page(req):
-# print("%s path is %s - host is %s" % (req, req.path, req.host))
-# print("connection is %s" % req.connection)
+ print("%s path is %s - host is %s" % (req, req.path, req.host))
+ print("connection is %s" % req.connection)
xframe = req.request_header("xframe")
-# if xframe != None:
-# print("xframe header present %s" % xframe)
+ if xframe != None:
+ print("xframe header present %s" % xframe)
if req.method == kore.METHOD_POST:
try:
length, body = req.body_read(1024)
@@ -52,6 +43,9 @@ def page(req):
req.response(200, body)
else:
req.populate_get()
+ id = req.argument("id")
+ if id != None:
+ print("got id of %s" % id)
req.response_header("content-type", "text/plain")
req.response(200, "hello 1234".encode("utf-8"))
return kore.RESULT_OK