Commit 115496a1 authored by Ivar Refsdal's avatar Ivar Refsdal

Better logging

parent 5730c9c3
......@@ -4,4 +4,4 @@ set -ex
docker build .
docker run --memory="100M" --publish=8090:8090
docker run -it --memory="100M" --publish=8090:8090
......@@ -17,20 +17,23 @@ app = flask.Flask(__name__)
@app.route('/', defaults={'path': ''}, methods = ['POST'])
@app.route('/<path:path>', methods = ['POST'])
def hello(path):'new request')
def custom_stream_factory(total_content_length, filename, content_type, content_length=None):
tmpfile = tempfile.NamedTemporaryFile('wb+')
tmpfile = tempfile.NamedTemporaryFile('wb+', prefix='flaskapp')"start receiving file ... filename => " + str(
return tmpfile
ms = measure_spent_time()
stream,form,files = werkzeug.formparser.parse_form_data(flask.request.environ, stream_factory=custom_stream_factory)
total_size = 0
for fil in files.values():
print("saved form name",, "submitted as", fil.filename, "to temporary file"," ".join(["saved form name",, "submitted as", fil.filename, "to temporary file",]))
total_size += os.path.getsize(
mb_per_s = "%.1f" % ((total_size / (1024.0*1024.0)) / ((1.0+ms(raw=True))/1000.0))
print("handling POST request, spent", ms(), "ms.", mb_per_s, "MB/s.", "Number of files:", len(files.values()))" ".join([str(x) for x in ["handling POST request, spent", ms(), "ms.", mb_per_s, "MB/s.", "Number of files:", len(files.values())]]))
process = psutil.Process(os.getpid())
print("memory usage: %.1f MiB" % (process.memory_info().rss / (1024.0*1024.0)))"memory usage: %.1f MiB" % (process.memory_info().rss / (1024.0*1024.0)))
return "Hello World!"
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment