This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask_sqlalchemy import SQLAlchemy | |
import flask_admin as admin | |
from flask_admin.contrib import sqla | |
# Create application | |
app = Flask(__name__) | |
# Create dummy secrey key so we can use sessions | |
app.config['SECRET_KEY'] = '123456790' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, redirect, url_for, request | |
import peewee | |
import flask_admin as admin | |
from flask_admin.contrib.peewee import ModelView | |
app = Flask(__name__) | |
app.config['SECRET_KEY'] = '123456790' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flask_wtf | |
import flask_admin as admin | |
from flask import Flask | |
from flask_sqlalchemy import SQLAlchemy | |
from flask_admin.contrib import sqla | |
# Create application | |
app = Flask(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
from flask import Flask | |
from flask_sqlalchemy import SQLAlchemy | |
import flask_admin as admin | |
from flask_admin.contrib import sqla | |
from sqlalchemy_utils import UUIDType | |
# Create application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set mailserver localhost | |
# don't alert when pid changed or when monit starts | |
set alert network@dallasmakerspace.org but not on { pid, instance } | |
check process apache with pidfile /run/apache2.pid | |
start program = "/etc/init.d/apache2 start" with timeout 60 seconds | |
stop program = "/etc/init.d/apache2 stop" | |
if cpu > 60% for 2 cycles then alert | |
if cpu > 80% for 5 cycles then restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def start_must_not_conflict(form, field): | |
print request.args.get('id') # get ID | |
if Event.query.filter(db.and_(Event.location == form.location.data, Event.start.between(form.start.data, form.end.data), Event.id != request.args.get('id'))).first(): # exclude ID from query | |
raise wtforms.validators.ValidationError('Start time conflicts with another request for the same time.') | |
form_args = dict( | |
start=dict(validators=[start_must_not_conflict]) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# how you need to format the body of the request | |
requestbody = """{ | |
"description": %s, | |
"summary": %s | |
} | |
""" % (json.dumps(description), json.dumps(summary)) # use json.dumps to escape string for the request body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
options = { | |
series: { | |
pie: { | |
innerRadius: 0.5, | |
show: true, | |
label: { | |
show: true, | |
formatter: function (label, series) { | |
console.log(series); | |
return '<div style="font-size:8pt;text-align:center;padding:2px; color: ' + series.color +';">' + label + '<br/>' + series.data[0][1] + '</div>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#data | |
old_list = [ | |
{'name': "matthew", 'test_result1': "A", 'test_result2': "A"}, | |
{'name': "steve", 'test_result1': "B", 'test_result2': "D"}, | |
{'name': "dave", 'test_result1': "C", 'test_result2': "F"} | |
] | |
new_list = [ | |
{'name': "steve", 'test_result1': "A", 'test_result2': "F"}, | |
{'name': "matthew", 'test_result1': "B", 'test_result2': "F"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from application import app | |
from flask import request, url_for, redirect | |
@app.route('/') | |
def index(): | |
modified_args = dict(request.args) | |
modified_args['key'] = 'modified_value' | |
return redirect(url_for('my_view', **modified_args)) |
OlderNewer