Now I'm sending data to client by Server Side Event
Can I seperate these data.
such as
sent data: 1.8
sent data: -7.3
sent data: 4.5
My code:
def cal_fft(name):
print("Starting " + name)
gevent.sleep(5)
while True:
n = len(y) # Length of signal
NFFT = n # ?? NFFT=2^nextpow2(length(y)) ??
k = np.arange(NFFT)
f0 = k*Fs/NFFT # double sides frequency range
f0 = f0[range(math.trunc(NFFT/2))] # single sied frequency range
Y = np.fft.fft(y)/NFFT # fft computing and normaliation
Y = Y[range(math.trunc(NFFT/2))] # single sied frequency range
#amplitude_Hz = 2*abs(Y)
phase_ang = np.angle(Y) * 180 / np.pi
q.put(phase_ang)
gevent.sleep(2)
def stream_data():
print("Starting streaming")
while True:
if not q.empty():
result = q.get()
print("sent data: ", result)
# print(result)
# yield 'event: fft
'
yield 'data: % s
' % str(result)
gevent.sleep(0.4)
else:
print("QUEUE empty!! Unable to stream @", time.ctime())
gevent.sleep(1) # Try again after 1 sec
# os._exit(1)
question from:
https://stackoverflow.com/questions/65839794/i-would-like-to-send-a-data-diffrent-ways-in-sse 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…