Skip to content

Instantly share code, notes, and snippets.

View doobeh's full-sized avatar

Anthony Plunkett doobeh

View GitHub Profile
{% extends 'parent.html' %}
{% block css %}
<link href = "{{ url_for('static', filename = 'base/child.css') }}" rel = "stylesheet">
{% endblock css%}
{% block content %}
<form>
<input name="foo"/>
</form>
@doobeh
doobeh / model.py
Created August 15, 2018 18:26
Why when the 110 value is set, doesn't the `get_history` see 100 as the deleted value?
def price_logger(mapper, connection, target):
data = target.__dict__.copy()
print('Update event caught')
print("Current Value:", data["retail"]) # Current value (working as expected)
value = get_history(target, 'retail')
print(f'Old value was {value}, new is {data["retail"]}')
print('-'*10)
class History(db.Model):
id = db.Column(db.Integer, primary_key=True)
from flask import Flask, request
from flask import json
from io import BytesIO
app = Flask(__name__)
app.config["MAX_CONTENT_LENGTH"] = 102400
@app.route('/', methods=['post', 'get'])
def upload():
@doobeh
doobeh / app.py
Last active July 12, 2017 15:24
reboot project
import requests
@app.route('/form', methods=['GET', 'POST'])
def form():
form = RebootForm()
ugly_messages = []
if form.validate_on_submit():
ip_addresses = form.available.data
for ip_address in ip_addresses:
requests.get('http://{}/rc.cgi?L=uirreboot.html&c=99'.format(ipaddress))
from flask import Flask, g, render_template
from flask.ext.login import LoginManager
import forms
import models
app = Flask(__name__)
app.secret_key = 'this is our super secret key. do not share it with anyone!'
login_manager = LoginManager()
login_manager.init_app(app)
@doobeh
doobeh / foo.txt
Created May 22, 2017 23:56
Links
http://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html#commit-your-changes
{% macro bsfield(field) -%}
{% set with_label = kwargs.pop('with_label', False) %}
{% set placeholder = '' %}
{% if not with_label %}
{% set placeholder = field.label.text %}
{% endif %}
<div class="form-group {% if field.errors %}error{% endif %}">
{% if with_label %}
<label for="{{ field.id }}">
{{ field.label.text }}{% if field.flags.required %} *{% endif %}:
@doobeh
doobeh / whatwhat.py
Created January 31, 2017 19:03
mattb problemo.
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
db = SQLAlchemy(app)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
app.config['SQLALCHEMY_ECHO'] = False
tags = db.Table('tags',
db.Column('tag_id', db.Integer, db.ForeignKey('tag.id')),
@doobeh
doobeh / aib.py
Created November 30, 2016 16:30
better example
from flask import Flask, request, jsonify, url_for
app = Flask(__name__)
app.secret_key = 'aib'
def home():
return 'Ok'
app.add_url_rule('/', 'foo', home)
@doobeh
doobeh / aib.py
Created November 30, 2016 16:29
add_url_rule
from flask import Flask, request, jsonify
app = Flask(__name__)
app.secret_key = 'aib'
def home():
return 'Ok'
app.add_url_rule('/', 'something', home)