Skip to content

Instantly share code, notes, and snippets.

View simanacci's full-sized avatar
💭
😷

simanacci

💭
😷
View GitHub Profile
@simanacci
simanacci / multiplecheckbox.py
Created April 25, 2020 20:45 — forked from juzten/multiplecheckbox.py
custom multiple checkbox field for wtforms and flask
from flask import Flask, render_template
from flask.ext.wtf import Form, widgets, SelectMultipleField
SECRET_KEY = 'development'
app = Flask(__name__)
app.config.from_object(__name__)
class MultiCheckboxField(SelectMultipleField):
widget = widgets.ListWidget(prefix_label=False)
@simanacci
simanacci / flask_profiler.py
Created October 29, 2019 06:21 — 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
"""
from flask import Flask, render_template, request
from flask_wtf import FlaskForm
from wtforms import SubmitField, SelectMultipleField, widgets
class MultiCheckboxField(SelectMultipleField):
widget = widgets.ListWidget(prefix_label=False)
option_widget = widgets.CheckboxInput()
class ExampleForm(FlaskForm):
foo = MultiCheckboxField('label'