feat: WebSocket upload (one TCP, no Cilium cycling), bump 1.0.9→1.0.10
Deploy loadtest / validate (push) Waiting to run
Deploy loadtest / validate (push) Waiting to run
This commit is contained in:
+28
-1
@@ -1,10 +1,37 @@
|
||||
import time
|
||||
import json
|
||||
import base64
|
||||
from flask import Flask, render_template, request
|
||||
from flask_sock import Sock
|
||||
|
||||
app = Flask(__name__)
|
||||
sock = Sock(app)
|
||||
|
||||
VERSION = '1.0.9'
|
||||
VERSION = '1.0.10'
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html', version=VERSION)
|
||||
|
||||
|
||||
@app.route('/health')
|
||||
def health():
|
||||
return {'ok': True, 'version': VERSION}
|
||||
|
||||
|
||||
@sock.route('/ws-upload')
|
||||
def ws_upload(ws):
|
||||
"""WebSocket: получает чанки, считает байты и время"""
|
||||
t0 = time.time()
|
||||
total = 0
|
||||
while True:
|
||||
chunk = ws.receive()
|
||||
if chunk is None:
|
||||
break
|
||||
total += len(chunk)
|
||||
elapsed = round((time.time() - t0) * 1000)
|
||||
ws.send(json.dumps({'ok': True, 'bytes': total, 'elapsed_ms': elapsed}))
|
||||
|
||||
|
||||
@app.route('/')
|
||||
|
||||
Reference in New Issue
Block a user