Пример #1
0
import flask



if app.debug:
    '''
    if not app.debug in product mode
    '''

    import logging


    '''
    when flask app was init, there is only one default debug level handler bind to the logger
    '''
    app.logger.handlers[0].setLevel(logging.INFO)

    '''
    from logging.handlers import SMTPHandler
    mail_handler = SMTPHandler('127.0.0.1', '*****@*****.**', app.config['ADMINS_EMAIL'], 'YourApplication Failed')
    mail_handler.setLevel(logging.ERROR)
    app.logger.addHandler(mail_handler)
    '''

    from logging import FileHandler
    file_handler = FileHandler('log')
    file_handler.setLevel(logging.INFO)
    app.logger.addHandler(file_handler)

app.run()
Пример #2
0
from twitter import app

if __name__ == '__main__':
    app.run(debug=True)
Пример #3
0
from twitter import app

if __name__ == '__main__':
    app.run()

#
# a = "fjla_fjlkj_kljalf"
# b = a.replace("_", " ")
# print(b)
Пример #4
0
import logging

from twitter import app
from twitter.data.database.db import DBConnection
from twitter.trends_logger import trends_logger
from twitter.util.location_util import *

with app.app_context():
    DBConnection.init_db(app)


@app.before_first_request
def setup():
    logging.basicConfig(level=logging.INFO)
    trends_logger.info("Initializing application...")
    populate_location_map()


@app.errorhandler(500)
def server_error(e):
    trends_logger.exception('An error occurred during a request.')
    return """
    An internal error occurred: <pre>{}</pre>
    See logs for full stacktrace.
    """.format(e), 500


if __name__ == "__main__":
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port)
Пример #5
0
        except ZeroDivisionError:
            hashtag_sentiment['data'].append(0)
            hashtag_distribution['data'].append(0)

    return jsonify(
        {
            'word_stats': word_stats,
            'date_stats': date_stats,
            'date_sentiment': date_sentiment,
            'hashtag_sentiment': hashtag_sentiment,
            'hashtag_distribution': hashtag_distribution
        }
    )


@app.route('/api/religion/')
def religion():
    """Calculates specific statistics related to religion."""

    pie_chart = {'labels': [], 'data': []}
    for tag in PRESET_TAGS.keys():
        pie_chart['labels'].append(tag)
        pie_chart['data'].append(
            len(db.session.query(Tag).having(Tag.tag == tag).one().tweets)
        )

    return jsonify({'pie_chart': pie_chart})

if __name__ == '__main__':
    app.run(host='0.0.0.0')
Пример #6
0
import os

from twitter import app

app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 3000)))