Skip to content

Instantly share code, notes, and snippets.

@vulcan25
vulcan25 / app.py
Created March 18, 2020 19:31 — forked from seanbehan/app.py
Flask with Django ORM
'''
Run the following commands (bc. gists don't allow directories)
pip install flask django dj-database-url psycopg2
mkdir -p app/migrations
touch app/__init__.py app/migrations/__init__.py
mv models.py app/
python manage.py makemigrations
python manage.py migrate
@vulcan25
vulcan25 / main.py
Created July 17, 2020 23:24 — forked from stewartadam/main.py
Simple Python proxy server based on Flask and Requests with support for GET and POST requests.
"""
A simple proxy server, based on original by gear11:
https://gist.github.com/gear11/8006132
Modified from original to support both GET and POST, status code passthrough, header and form data passthrough.
Usage: http://hostname:port/p/(URL to be proxied, minus protocol)
For example: http://localhost:5000/p/www.google.com
"""
import re
@vulcan25
vulcan25 / README.md
Last active February 29, 2024 13:26
Create ZIP file in memory from PIL images and serve with Flask

First do pip install flask Pillow in your venv :)

@vulcan25
vulcan25 / flask_profiler.py
Created October 28, 2021 16:51 — forked from shreyansb/flask_profiler.py
A profiler for Flask apps
"""
This module provides a simple WSGI profiler middleware for finding
bottlenecks in web application. It uses the profile or cProfile
module to do the profiling and writes the stats to the stream provided
To use, run `flask_profiler.py` instead of `app.py`
see: http://werkzeug.pocoo.org/docs/0.9/contrib/profiler/
and: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvi-debugging-testing-and-profiling
"""
@vulcan25
vulcan25 / cprofile.py
Created November 6, 2021 21:02 — forked from rfong/cprofile.py
Django profiling decorator
import cProfile
import pstats
from django.utils.functional import wraps
def cprofile(sort_by='cumulative', n=20):
"""Decorator to profile a function."""
def decorator(func):
@wraps(func)