Spaces:
Runtime error
Runtime error
Hugo Garcia-Cotte
commited on
Commit
•
418b498
1
Parent(s):
4abf8ac
Add first version of the game file
Browse files
app.py
CHANGED
@@ -4,12 +4,30 @@ import subprocess
|
|
4 |
# Create an input text box
|
5 |
input_text = st.text_input('Enter some text')
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
# Create an input text box
|
5 |
input_text = st.text_input('Enter some text')
|
6 |
|
7 |
+
def start(executable_file):
|
8 |
+
return subprocess.Popen(
|
9 |
+
executable_file,
|
10 |
+
stdin=subprocess.PIPE,
|
11 |
+
stdout=subprocess.PIPE,
|
12 |
+
stderr=subprocess.PIPE)
|
13 |
+
|
14 |
+
|
15 |
+
def read(process):
|
16 |
+
return process.stdout.readline().decode("utf-8").strip()
|
17 |
+
|
18 |
+
|
19 |
+
def write(process, message):
|
20 |
+
process.stdin.write(f"{message.strip()}\n".encode("utf-8"))
|
21 |
+
process.stdin.flush()
|
22 |
+
|
23 |
+
|
24 |
+
def terminate(process):
|
25 |
+
process.stdin.close()
|
26 |
+
process.terminate()
|
27 |
+
process.wait(timeout=0.2)
|
28 |
+
|
29 |
+
|
30 |
+
process = start("./dummy.py")
|
31 |
+
write(process, "hello dummy")
|
32 |
+
st.write(read(process))
|
33 |
+
terminate(process)
|