2014-08-06 09:43:40 +00:00
|
|
|
#!/usr/bin/env python2
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
2014-08-14 15:55:18 +00:00
|
|
|
import redis
|
|
|
|
import ConfigParser
|
|
|
|
import json
|
2016-07-21 11:44:22 +00:00
|
|
|
import datetime
|
2016-08-19 14:53:46 +00:00
|
|
|
import time
|
2016-08-13 13:24:57 +00:00
|
|
|
import calendar
|
2014-12-24 14:42:20 +00:00
|
|
|
from flask import Flask, render_template, jsonify, request
|
2014-08-06 09:43:40 +00:00
|
|
|
import flask
|
2014-08-26 15:33:28 +00:00
|
|
|
import os
|
2016-07-05 14:53:03 +00:00
|
|
|
import sys
|
|
|
|
sys.path.append(os.path.join(os.environ['AIL_BIN'], 'packages/'))
|
|
|
|
import Paste
|
2016-07-21 11:44:22 +00:00
|
|
|
from Date import Date
|
2014-12-24 14:42:20 +00:00
|
|
|
|
2016-12-09 07:46:37 +00:00
|
|
|
# Import config
|
|
|
|
import Flask_config
|
2016-08-19 11:34:02 +00:00
|
|
|
|
2016-12-09 07:46:37 +00:00
|
|
|
# CONFIG #
|
|
|
|
cfg = Flask_config.cfg
|
2016-08-24 16:00:05 +00:00
|
|
|
|
2016-12-09 07:46:37 +00:00
|
|
|
Flask_config.app = Flask(__name__, static_url_path='/static/')
|
|
|
|
app = Flask_config.app
|
2014-08-26 15:33:28 +00:00
|
|
|
|
2016-12-09 07:46:37 +00:00
|
|
|
# import routes and functions from modules
|
|
|
|
import Flask_dashboard
|
|
|
|
import Flask_trendingcharts
|
|
|
|
import Flask_trendingmodules
|
|
|
|
import Flask_browsepastes
|
|
|
|
import Flask_sentiment
|
|
|
|
import Flask_terms
|
|
|
|
import Flask_search
|
|
|
|
import Flask_showpaste
|
2014-08-26 15:33:28 +00:00
|
|
|
|
2016-07-05 14:53:03 +00:00
|
|
|
def list_len(s):
|
|
|
|
return len(s)
|
|
|
|
app.jinja_env.filters['list_len'] = list_len
|
|
|
|
|
2016-08-04 09:55:38 +00:00
|
|
|
|
2016-08-09 09:59:36 +00:00
|
|
|
# ========= CACHE CONTROL ========
|
|
|
|
@app.after_request
|
|
|
|
def add_header(response):
|
|
|
|
"""
|
|
|
|
Add headers to both force latest IE rendering engine or Chrome Frame,
|
|
|
|
and also to cache the rendered page for 10 minutes.
|
|
|
|
"""
|
|
|
|
response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
|
|
|
|
response.headers['Cache-Control'] = 'public, max-age=0'
|
|
|
|
return response
|
2016-07-21 11:44:22 +00:00
|
|
|
|
2016-12-09 07:46:37 +00:00
|
|
|
# ============ MAIN ============
|
2016-07-08 08:19:24 +00:00
|
|
|
|
2014-08-06 09:43:40 +00:00
|
|
|
if __name__ == "__main__":
|
2014-08-14 15:55:18 +00:00
|
|
|
app.run(host='0.0.0.0', port=7000, threaded=True)
|