test libmemcache and libffi · snippet-java/python-buildpack@957fbdc · GitHub
Skip to content

Commit 957fbdc

Browse files
committed
test libmemcache and libffi
[#90697220] [#90697216]
1 parent fdd4aa9 commit 957fbdc

5 files changed

Lines changed: 68 additions & 3 deletions

File tree

Lines changed: 23 additions & 0 deletions
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from cffi import FFI
2+
ffi = FFI()
3+
ffi.cdef("""
4+
int printf(const char *format, ...);
5+
""")
6+
C = ffi.dlopen(None) # loads the entire C namespace
7+
arg = ffi.new("char[]", "world") # equivalent to C code: char arg[] = "world";
8+
C.printf("hi there, %s!\n", arg)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pylibmc
2+
3+
try:
4+
mc = pylibmc.Client(["127.0.0.1"])
5+
mc["some_key"] = "Some value"
6+
7+
except pylibmc.ConnectionError:
8+
print "Could not connect"
9+
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
from flask import Flask
1+
from flask import Flask, request
2+
import subprocess
3+
24
app = Flask(__name__)
35

46
@app.route("/")
57
def hello():
68
return "Hello, World!"
79

8-
if __name__ == "__main__":
9-
app.run()
10+
@app.route('/execute', methods=['POST'])
11+
def execute():
12+
with open('runtime.py', 'w') as f:
13+
f.write(request.values.get('code'))
14+
return subprocess.check_output(["python", "runtime.py"])
15+
16+
app.debug=True
Lines changed: 18 additions & 0 deletions

0 commit comments

Comments
 (0)