chris-rannou HF staff commited on
Commit
2648b2e
1 Parent(s): 9b77346

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -20
app.py CHANGED
@@ -1,20 +1,29 @@
1
- """ App
2
- """
3
-
4
- import gradio as gr
5
- import time
6
- import os
7
-
8
- MB = 1024*1024
9
- def eat_memory():
10
- mem = []
11
- while True:
12
- mem += ['c' * (100 * MB)]
13
- time.sleep(0.1)
14
-
15
- def greet(name):
16
- return "Hello " + name + ", secret: " + os.environ.get("TEST_ENV_SECRET")
17
-
18
- # comment 2
19
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
20
- iface.launch()
 
 
 
 
 
 
 
 
 
 
1
+ import socket
2
+
3
+ # Set up a TCP/IP server
4
+ tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
5
+
6
+ # Bind the socket to server address and port 50052
7
+ server_address = ('localhost', 50052)
8
+ tcp_socket.bind(server_address)
9
+
10
+ # Listen on port 50052
11
+ tcp_socket.listen(1)
12
+
13
+ while True:
14
+ print("Waiting for connection")
15
+ connection, client = tcp_socket.accept()
16
+
17
+ try:
18
+ print("Connected to client IP: {}".format(client))
19
+
20
+ # Receive and print data 32 bytes at a time, as long as the client is sending something
21
+ while True:
22
+ data = connection.recv(32)
23
+ print("Received data: {}".format(data))
24
+
25
+ if not data:
26
+ break
27
+
28
+ finally:
29
+ connection.close()