104, ‘Connection reset by peer’ socket error, or When does closing a socket result in a RST rather than FIN?

I’ve had this problem. See The Python “Connection Reset By Peer” Problem. You have (most likely) run afoul of small timing issues based on the Python Global Interpreter Lock. You can (sometimes) correct this with a time.sleep(0.01) placed strategically. “Where?” you ask. Beats me. The idea is to provide some better thread concurrency in and … Read more

Capture arbitrary path in Flask route

Use the path converter to capture arbitrary length paths: <path:path> will capture a path and pass it to the path argument. The default converter captures a single string but stops at slashes, which is why your first url matched but the second didn’t. If you also want to match the root directory (a leading slash … Read more

Flask url_for generating http URL instead of https

With Flask 0.10, there will be a much better solution available than wrapping url_for. If you look at https://github.com/mitsuhiko/flask/commit/b5069d07a24a3c3a54fb056aa6f4076a0e7088c7, a _scheme parameter has been added. Which means you can do the following: url_for(‘secure_thingy’, _external=True, _scheme=”https”, viewarg1=1, …) _scheme sets the URL scheme, generating a URL like https://.. instead of http://. However, by default Flask only … Read more

tech