from DevOps team {rduplain,mattd,teebes}, to mobile developers at WillowTree Apps
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
"Serve a Flask app on a sub-url during localhost development." | |
from flask import Flask | |
APPLICATION_ROOT = '/spam' | |
app = Flask(__name__) | |
app.config.from_object(__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 cookielib | |
import urllib | |
import urllib2 | |
class Client(object): | |
def __init__(self): | |
self.cookie_jar = cookielib.CookieJar() | |
self.opener = urllib2.build_opener( | |
urllib2.HTTPCookieProcessor(self.cookie_jar)) |
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 celery import abstract | |
from celery import current_app | |
from kombu import Exchange, Queue | |
from kombu.mixins import ConsumerMixin | |
# need to subclass the result backend so that it uses a topic exchange | |
# instead of direct, and send the results for tasks using a routing_key | |
# of the format: |
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
# Using SQLAlchemy 0.7.5 and Flask-SQLAlchemy 0.15. | |
from flask import Flask | |
from flask.ext.sqlalchemy import SQLAlchemy, BaseQuery, _QueryProperty | |
from models import Base | |
SQLALCHEMY_DATABASE_URI = 'sqlite:///app.db' | |
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.celery import install_commands | |
from flask.ext.script import Manager | |
app = Flask(__name__) | |
manager = Manager(app) | |
install_commands(manager) | |
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, make_response, redirect, session, url_for | |
SECRET_KEY = 'develop' | |
app = Flask(__name__) | |
app.config.from_object(__name__) | |
@app.route('/') | |
def index(): | |
return '<a href="%s">Go here.</a>' % url_for('do_redirect') |
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 spam(a, b, c=None): | |
return a, b, c | |
if __name__ == '__main__': | |
print "spam(b='b', a='a', c='c') =>", spam(b='b', a='a', c='c') | |
print "spam(b='b', a='a') =>", spam(b='b', a='a') | |
try: | |
spam(a='a', c='c') | |
except TypeError, e: |
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
server { | |
listen 80; | |
server_name _; | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
location / { | |
proxy_pass http://127.0.0.1:8000/; |
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
# http://flask.pocoo.org/mailinglist/archive/2012/4/10/serving-static-file-from-a-separate-domain-in-production/ | |
from flask import Flask, url_for | |
# Uncomment to set server name. | |
# SERVER_NAME = 'mianos.com' | |
app = Flask(__name__, static_folder=None) | |
app.config.from_object(__name__) | |
app.add_url_rule('/<path:filename>', endpoint='static', |