Skip to content

Instantly share code, notes, and snippets.

@cuongitl
cuongitl / python-flask-catch-all route.py
Created June 21, 2022 13:16
Python Flask Catch-all route
"""It may be useful to have one catch-all view where you handle complex logic yourself based on the path.
This example uses two rules:
- First rule specifically catches
- Second rule catches arbitrary paths with the built-in path converter.
The path converter matches any string (including slashes)."""
@app.route('/', defaults={'u_path': ''})
@app.route('/<path:u_path>')
def catch_all(u_path):
print(repr(u_path))
@cuongitl
cuongitl / python_flask_nginx_befhind_cloudflare.conf
Created September 15, 2021 09:02
python flask nginx behind cloudflare
# https://support.cloudflare.com/hc/en-us/articles/200170786-Restoring-original-visitor-IPs#C5XWe97z77b3XZV
server {
server_name lecuong.info;
listen *:80;
client_max_body_size 100M;
proxy_read_timeout 600s;
proxy_buffers 16 4k;
proxy_buffer_size 2k;
location ^~ /.well-known/acme-challenge/ {
@cuongitl
cuongitl / python_mysql_connector.md
Created July 12, 2021 04:53
Mysql connector with python

First of all you have to start your xamp server

Install Package

pip install mysql-connector-python

Connection Establishment Code