View app.py
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 | |
from sqlalchemy.ext.associationproxy import association_proxy | |
from sqlalchemy.orm import relationship, backref | |
import flask_admin as admin | |
from flask_admin.contrib import sqla | |
# Create application | |
app = Flask(__name__) |
View test.py
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 _pick_by_class_ref(self, cls_ref, comparision_type="exact"): | |
func = getattr(self, comparision_type) | |
try: | |
_refs = self.db["key"][cls_ref] | |
except KeyError: | |
return [] | |
else: | |
_item = self.db["info"][_refs[0]] | |
_level = _item["level"] | |
if comparision_type != "better": |
View demo.html
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
<html> | |
<body> | |
Hello {{ subdomain }}! | |
<img src="{{ url_for('static', subdomain=subdomain, filename='avatar.jpeg', _external=True) }}"></img> | |
</body> | |
</html> |
View demo.py
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 os.path as op | |
from flask import Flask | |
from flask.helpers import locked_cached_property | |
from jinja2 import FileSystemLoader | |
class BubbleApp(Flask): | |
def __init__(self): |
View gist:3acbdc9245202ca437ef
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
<?xml version="1.0" encoding="utf-8"?> | |
<ISBoxerToolkitProfile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="41" VersionMinor="1" BuildDate="9/1/2015 12:32:02 AM"> | |
<CharacterSet> | |
<ExecuteOnLoad> | |
<RoundRobin>false</RoundRobin> | |
</ExecuteOnLoad> | |
<Name>Diablo III</Name> | |
<Description>Generated by ISBoxer 41 Quick Setup Wizard - 2/1/2015</Description> | |
<DisableFPSIndicator>false</DisableFPSIndicator> | |
<DisableForceWindowed>false</DisableForceWindowed> |
View safe_redirect.py
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 urlparse import urlparse, urljoin | |
from flask import request, url_for, redirect | |
from myapp.app import app | |
def is_safe_url(target): | |
ref_url = urlparse(request.host_url) | |
test_url = urlparse(urljoin(request.host_url, target)) |
View gist.py
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 mongoengine import connect | |
from flask.ext.admin import Admin | |
from flask.ext.admin.contrib.mongoengine import ModelView | |
from flask.ext.mongoengine import MongoEngine | |
class Config(object): | |
DEBUG = True |
View demo.py
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
# Recursively check all combinations with +- | |
def check(step, acc, ops, digits): | |
if step >= len(digits): | |
if acc == 100: | |
row = '' | |
for pair in zip(digits, ops): | |
row += '%s %s ' % pair | |
print '%s%s' % (row, digits[-1]) |
View base.py
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
class BaseModelView(ModelView): | |
list_template = 'admin/model_list.html' | |
export_columns = None | |
# Exporting | |
def _get_data_for_export(self): | |
view_args = self._get_list_extra_args() | |
# Map column index to column name |
View gist:18414b7aff0a3c862582
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.ext.sqlalchemy import SQLAlchemy | |
from flask.ext.admin import Admin | |
from flask.ext.admin.contrib.sqla import ModelView | |
app = Flask(__name__) | |
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite' | |
db = SQLAlchemy(app) |
NewerOlder