35 lines
726 B
Python
35 lines
726 B
Python
import time
|
|
from flask import Flask, render_template, request
|
|
|
|
app = Flask(__name__)
|
|
|
|
VERSION = '1.0.1'
|
|
|
|
|
|
@app.route('/')
|
|
def index():
|
|
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__':
|
|
app.run(host='0.0.0.0', port=5000, debug=True)
|