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
{% extends 'admin/model/edit.html' %} | |
{% macro table(columns, items, endpoint) %} | |
<table class="table table-striped table-bordered model-list"> | |
<thead> | |
<tr> | |
<th></th> | |
{% for c in columns %} | |
<th>{{ c }}</th> | |
{% endfor %} |
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, request, url_for | |
from flask.ext.sqlalchemy import SQLAlchemy | |
from flask.ext.admin.contrib import sqlamodel | |
from flask.ext import admin | |
# Create application | |
app = Flask(__name__) | |
# Create dummy secrey key so we can use sessions |
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 |
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
{% extends 'admin/master.html' %} | |
{% import 'admin/lib.html' as lib with context %} | |
{% block body %} | |
{% call lib.form_tag() %} | |
{{ lib.render_form_fields(form) }} | |
<input type="submit" /> | |
{% endcall %} | |
{% endblock %} |
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 import admin, wtf | |
from flask.ext.admin.contrib import sqlamodel | |
app = Flask(__name__) | |
app.config['SECRET_KEY'] = '123456790' | |
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.sqlite' | |
db = SQLAlchemy(app) |
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__) |
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> |
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
1. pip install -r reqs.pip | |
2. server.py | |
3. open client.html in browser | |
4. redis-cli publish push '123456' | |
5. check browser console |
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
# -*- coding: utf-8 -*- | |
from tornado import ioloop, web, gen, httpclient | |
from sockjs.tornado import SockJSConnection, SockJSRouter | |
class IndexHandler(web.RequestHandler): | |
"""Regular HTTP handler to serve the ping page""" | |
def get(self): |
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 import admin, wtf | |
from flask.ext.admin.model import template | |
from flask.ext.admin.contrib import sqlamodel | |
from flask.ext.admin.contrib.sqlamodel import filters | |
# Create application |
NewerOlder