This file contains hidden or 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.wtf import Form | |
| from flask.ext.babel import gettext | |
| from wtforms import SelectField, TelField, TextField, FormField, Fieldlist, SubmitField | |
| from wtforms.validators import Optional, Required | |
| app = Flask(__name__) | |
| db = SQLAlchemy(app) |
This file contains hidden or 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 logging | |
| class QueueHandler(logging.Handler): | |
| """ | |
| This handler sends events to a queue. Typically, it would be used together | |
| with a multiprocessing Queue to centralise logging to file in one process | |
| (in a multi-process application), so as to avoid file write contention | |
| between processes. | |
| This code is new in Python 3.2, but this class can be copy pasted into |
This file contains hidden or 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 logging | |
| try: | |
| import Queue as queue | |
| except ImportError: | |
| import queue | |
| import threading | |
| class QueueHandler(logging.Handler): | |
| """ | |
| This handler sends events to a queue. Typically, it would be used together |
This file contains hidden or 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
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import Queue | |
| import threading | |
| import urllib2 | |
| import time | |
| hosts = ['http://yahoo.com', 'http://google.com', 'http://amazon.com', | |
| 'http://ibm.com', 'http://apple.com'] |