feat: /upload эндпоинт, кнопка Загрузить, прогресс-бары, скорость, версия v1.0.0
Deploy loadtest / validate (push) Waiting to run
Deploy loadtest / validate (push) Waiting to run
This commit is contained in:
+24
-2
@@ -1,11 +1,33 @@
|
||||
from flask import Flask, render_template
|
||||
import time
|
||||
from flask import Flask, render_template, request
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
VERSION = '1.0.0'
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
return render_template('index.html', version=VERSION)
|
||||
|
||||
|
||||
@app.route('/health')
|
||||
def health():
|
||||
return {'ok': True, 'version': VERSION}
|
||||
|
||||
|
||||
@app.route('/upload', methods=['POST'])
|
||||
def upload():
|
||||
t0 = time.time()
|
||||
total = 0
|
||||
for f in request.files.values():
|
||||
while True:
|
||||
chunk = f.read(8192)
|
||||
if not chunk:
|
||||
break
|
||||
total += len(chunk)
|
||||
elapsed = round((time.time() - t0) * 1000)
|
||||
return {'ok': True, 'bytes': total, 'elapsed_ms': elapsed}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user