Beispiel #1
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    bootstrap.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    babel.init_app(app)
    admin.init_app(app)
    csrf.init_app(app)

    from .main import main as main_blueprint

    app.register_blueprint(main_blueprint)

    from .user import user as user_blueprint

    app.register_blueprint(user_blueprint)

    ck = Blueprint("ck_page", __name__, static_folder=chartkick.js(), static_url_path="/static")
    app.register_blueprint(ck, url_prefix="/ck")
    app.jinja_env.add_extension("chartkick.ext.charts")

    return app
Beispiel #2
0
def graphic():
    COUCHDB_SERVER = 'http://*****:*****@115.146.84.44:5984/'
    COUCHDB_DATABASE = 'db_test'
    DOC = "scenario3"
    couch = couchdb.Server(COUCHDB_SERVER)
    db = couch[COUCHDB_DATABASE]
    #print(db[document])

    pre_data = db[DOC]['result']
    data = pre_data['features']

    # data=[{u'late_slp_rank': 1, u'eco_index_rank': 1, u'Type': u'Feature', u'id': u'abc001', u'vic_loca_2': u'MELBOURNE'}, {u'late_slp_rank': 3, u'eco_index_rank': 10, u'Type': u'Feature', u'id': u'abc002', u'vic_loca_2': u'Calton'}, {u'late_slp_rank': 13, u'eco_index_rank': 9, u'Type': u'Feature', u'id': u'abc003', u'vic_loca_2': u'Parkville'}]

    print(chartkick.js())
    print(app.static_folder)
    app.jinja_env.add_extension("chartkick.ext.charts")
    col1 = []
    col2 = []
    col3 = []
    col4 = []
    bar_data = {}
    for x in data:
        if x['late_slp_rank'] is None or x['eco_index_rank'] is None:
            continue
        else:
            col1.append(x['vic_loca_2'])
            col2.append(x['late_slp_rank'])
            col3.append(x['eco_index_rank'])
            col4.append(x['late_slp_rank'] - x['eco_index_rank'])

    for x in range(len(col1)):
        bar_data[col1[x]] = col4[x]

######################
    new_col1 = col1[0:15]
    new_col2 = col2[0:15]
    new_col3 = col3[0:15]
    new_col4 = col4[0:15]
    ######################
    return render_template("graph.html",
                           rows=zip(new_col1, new_col2, new_col3, new_col4),
                           bar_data=bar_data)
Beispiel #3
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    db.init_app(app)
    db.app = app

    bootstrap.init_app(app)
    login_manager.init_app(app)
    redis_store.init_app(app)

    # 注册蓝本
    from app.home import home
    app.register_blueprint(home, url_prefix="")

    # 增加auth蓝本
    from app.auth import auth
    app.register_blueprint(auth, url_prefix="/auth")

    from app.supervisor_bp import supervisor
    app.register_blueprint(supervisor, url_prefix='/supervisor')

    from app.redis_bp import redis
    app.register_blueprint(redis, url_prefix="/redis")

    # 附加路由和自定义的错误页面
    from errors import error_404, error_500
    app.register_error_handler(404, error_404)
    app.register_error_handler(500, error_500)

    # 加入报表有关的配置
    ck = Blueprint('ck_bp',
                   __name__,
                   static_folder=chartkick.js(),
                   static_url_path='/static')
    app.register_blueprint(ck, url_prefix='/ck')
    app.jinja_env.add_extension("chartkick.ext.charts")

    # db.create_all()

    return app
Beispiel #4
0
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

#STATIC_URL = ESTATICOS
STATIC_URL = '/static/'
STATIC_ROOT = 'staticfiles'

TEMPLATE_DIRS = [os.path.join(BASE_DIR, "Sidefi", "templates")]

#AUTH_USER_MODEL = 'Sidefi.Usuarios'

AUTH_PROFILE_MODULE = 'Sidefi.UserProfile'


STATICFILES_DIRS = (
    chartkick.js(),
)



SESSION_COOKIE_AGE = 3600

SESSION_EXPIRE_AT_BROWSER_CLOSE = True


EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.mail.yahoo.com'
EMAIL_HOST_USER = '******'
EMAIL_HOST_PASSWORD = '******'
EMAIL_PORT = 465
EMAIL_USE_SSL = True
Beispiel #5
0
import os,binascii
from flask import Flask, request, session, g, redirect, url_for, abort, \
     render_template, flash, Blueprint
from flask import send_from_directory
import datetime, chartkick
import json
from pprint import pprint
import logging
from loklak import Loklak
from collections import Counter

app = Flask(__name__)
ck = Blueprint('ck_page', __name__, static_folder=chartkick.js(), static_url_path='/static')
app.register_blueprint(ck, url_prefix='/ck')
app.jinja_env.add_extension("chartkick.ext.charts")

@app.route('/visualize', methods=['POST'])
def visualize():
	q = request.form['q']
	l = Loklak()	
	data = l.search(q)
	statuses = data['statuses']
	if(len(statuses) == 0):
		return render_template('404.html')
	emotions = []
	languages = []
	countries = []
	for status in statuses:
		try:
			emotion = status['classifier_emotion']
			language = status['classifier_language']
Beispiel #6
0
dagbag = models.DagBag(conf.get('core', 'DAGS_FOLDER'))
utils.pessimistic_connection_handling()

app = Flask(__name__)
app.config['SQLALCHEMY_POOL_RECYCLE'] = 3600

login_manager.init_app(app)
app.secret_key = 'airflowified'

cache = Cache(
    app=app, config={'CACHE_TYPE': 'filesystem', 'CACHE_DIR': '/tmp'})

# Init for chartkick, the python wrapper for highcharts
ck = Blueprint(
    'ck_page', __name__,
    static_folder=chartkick.js(), static_url_path='/static')
app.register_blueprint(ck, url_prefix='/ck')
app.jinja_env.add_extension("chartkick.ext.charts")


class DateTimeForm(Form):
    # Date filter form needed for gantt and graph view
    execution_date = DateTimeField(
        "Execution date", widget=DateTimePickerWidget())


class GraphForm(Form):
    execution_date = DateTimeField(
        "Execution date", widget=DateTimePickerWidget())
    arrange = SelectField("Layout", choices=(
        ('LR', "Left->Right"),
Beispiel #7
0
from django.conf import settings

from jinja2 import TemplateSyntaxError as Jinja2TemplateSyntaxError
from jinja2 import Environment
from jinja2 import FileSystemLoader

import chartkick

# python 2.6 support
if not hasattr(unittest.TestCase, "assertIn"):
    import unittest2 as unittest


settings.configure()
settings.INSTALLED_APPS = ("chartkick",)
settings.STATICFILES_DIRS = (chartkick.js(),)
settings.STATIC_URL = ""


class TestsBase(object):

    TemplateSyntaxError = None

    def render(self, template, context=None):
        raise NotImplementedError

    def test_missing_vaiable(self):
        self.assertRaises(self.TemplateSyntaxError, self.render, "{% line_chart %}")

    def test_empty(self):
        chart = self.render("{% line_chart data %}", dict(data={}))
Beispiel #8
0

@app.errorhandler(404)
def not_found(error):
    return render_template("error.html", error=error), 404


db = SQLAlchemy(app)

# Import Blueprint modules.
from app.sessions.routes import mod_sessions
from app.players.routes import mod_players
from app.missions.routes import mod_missions


ck = Blueprint("ck_page", __name__, static_folder=chartkick.js(), static_url_path="/static")

# Register Blueprint(s)
app.register_blueprint(mod_sessions)
app.register_blueprint(mod_players)
app.register_blueprint(mod_missions)
app.register_blueprint(ck, url_prefix="/ck")
app.jinja_env.add_extension("chartkick.ext.charts")


db.create_all(bind=["ark_a2"])
db.create_all(bind=["compass"])
db.create_all(bind=["ark_forums"])


# pass into database, its first run
Beispiel #9
0
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'es'
LANGUAGES = [
    ('en', _('English')),
    ('es', _('Spanish')),
]
USE_I18N = True
USE_L10N = True

LOCALE_PATHS = (os.path.join(BASE_DIR, 'locale'), )

SITE_ID = 1

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), chartkick.js()]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

# Make this unique, and don't share it with anybody.
SECRET_KEY = '****'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
Beispiel #10
0
#!F:/jigoog/logforseo/logforseo
import log2
from flask import Flask, jsonify, render_template, request
import chartkick

app = Flask(__name__, static_folder=chartkick.js())
app.jinja_env.add_extension("chartkick.ext.charts")


@app.route('/')
@app.route('/index')
def index():
    data = {
        '11-7': 300,
        '11-8': 30,
        '11-9': 700,
        '11-10': 200,
        '11-11': 500,
        '11-12': 20,
        '11-13': 370,
        '11-14': 630,
        '11-15': 30,
        '11-16': 80
    }
    return render_template('show.html', data=data)


if __name__ == "__main__":
    app.run(debug=True)
Beispiel #11
0
    'profile_lipids',
    'qandr',
    'routines',
    'specialist',
    'symptoms',
    'weight_size',
    'audios',
    'directory',
    'postman',
    'relationships',
    'chartkick',
    'pybb',
)

import chartkick
STATICFILES_DIRS = (chartkick.js(), )

CKEDITOR_UPLOAD_PATH = "uploads/"

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'Full',
    },
    'zinnia-content': {
        'toolbar_Zinnia': [
            ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
            ['Undo', 'Redo'],
            ['Scayt'],
            ['Link', 'Unlink', 'Anchor'],
            ['Image', 'Table', 'HorizontalRule', 'SpecialChar'],
            ['Source'],
Beispiel #12
0
import config

from flask import Flask, render_template
from gravity import chartdata, store
from couchbase import Couchbase
import datetime
import time
import chartkick


def connect_db():
    return Couchbase.connect(host=config.DB_SERVER, bucket="default", quiet=True)

db = connect_db()

app = Flask('gravity-charts', static_folder=chartkick.js(), static_url_path='/static')
app.jinja_env.add_extension("chartkick.ext.charts")

@app.route('/')
def index():
    starttime = datetime.datetime(year=2013, month=8, day=9, hour=20)
    endtime = datetime.datetime(year=2013, month=8, day=9, hour=23)

    last_update_raw = store.get_last_record(db, 0)
    last_update_datetime = datetime.datetime.strptime("{0} {1}".format(last_update_raw[0], last_update_raw[1]),
                                                      "%Y %j")
    last_update = last_update_datetime.strftime("%d.%m.%Y")

    granularity = (int(time.mktime(endtime.timetuple())) - int(time.mktime(starttime.timetuple()))) / config.NUMBER_OF_POINTS

    deviation1, pressure1 = chartdata.get(db, 0, starttime, endtime, granularity=granularity)
Beispiel #13
0
        'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static', 'static_root')
import chartkick
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static',
                                 'static_dir'), chartkick.js())
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
Beispiel #14
0
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ""

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = ""

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = "/static/"

# Additional locations of static files
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"), chartkick.js())

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    "django.contrib.staticfiles.finders.FileSystemFinder",
    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
    #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = "o#ta+8a!9xhbgmupm($rw6n-k$1o#=hdy5j3=k-^kccc104!$_"

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    "django.template.loaders.filesystem.Loader",
Beispiel #15
0
TIME_ZONE = 'Asia/Kolkata'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'

import chartkick  ##for chartkicks
STATICFILES_DIRS = [
    chartkick.js(),  ##for charticks,
    os.path.join(BASE_DIR, 'static'),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'assets')

### images assets from form to db
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

## to change input time to am/pm
TIME_INPUT_FORMATS = [
    '%I:%M %p'  # 6:22 PM
]

##crispy form template
CRISPY_TEMPLATE_PACK = 'bootstrap4'
Beispiel #16
0
from glob import glob
from werkzeug import secure_filename
from functools import wraps
from flask import request, Response
from app.utils import get_env
from flask import send_from_directory


app = Flask(__name__)
UPLOAD_PATH = os.environ['HOME'] + '/last-capture'
if not os.path.exists(UPLOAD_PATH):
    os.makedirs(UPLOAD_PATH)
app.config['UPLOAD_FOLDER'] = UPLOAD_PATH

# Chartkick initialization
ck = Blueprint('ck_page', __name__, static_folder=chartkick.js(),
               static_url_path='/static')
app.register_blueprint(ck, url_prefix='/ck')
app.jinja_env.add_extension("chartkick.ext.charts")

from datetime import datetime
@app.route("/")
def view_home():
    try:
        last_capture_str = os.path.basename(glob(app.config['UPLOAD_FOLDER'] + '/*')[0])[:-4]
        dt = datetime.strptime(last_capture_str, "%Y%m%d-%H%M%S")
        last_capture = "%s.%s.%s %02d:%02d" % (dt.day, dt.month, dt.year, dt.hour, dt.minute)
    except:
        last_capture = None
    return render_template('home.html',
                           last_capture=last_capture,
Beispiel #17
0
from django.conf import settings

from jinja2 import TemplateSyntaxError as Jinja2TemplateSyntaxError
from jinja2 import Environment
from jinja2 import FileSystemLoader

import chartkick

# python 2.6 support
if not hasattr(unittest.TestCase, 'assertIn'):
    import unittest2 as unittest


settings.configure()
settings.INSTALLED_APPS = ('chartkick',)
settings.STATICFILES_DIRS = (chartkick.js(),)
settings.STATIC_URL = ''


class TestsBase(object):

    TemplateSyntaxError = None

    def render(self, template, context=None):
        raise NotImplementedError

    def test_missing_vaiable(self):
        self.assertRaises(self.TemplateSyntaxError,
                          self.render, '{% line_chart %}')

    def test_empty(self):
Beispiel #18
0
    AWS_ACCESS_KEY_ID = config("DO_ACCESS_KEY_ID")
    AWS_SECRET_ACCESS_KEY = config("DO_SECRET_ACCESS_KEY")

    AWS_STORAGE_BUCKET_NAME = config("DO_STORAGE_BUCKET_NAME")
    AWS_S3_ENDPOINT_URL = config("DO_S3_ENDPOINT_URL")
    AWS_S3_CUSTOM_DOMAIN = config("DO_S3_CUSTOM_DOMAIN")
    # Set the cache to 7 days. 86400 seconds/day * 7
    AWS_S3_OBJECT_PARAMETERS = {
        "CacheControl": "max-age=604800",
        "ACL": "public-read",
    }
    AWS_LOCATION = "static"

    STATICFILES_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"

    STATICFILES_DIRS = (chartkick.js(), BASE_DIR / "static")
    STATIC_URL = f"{AWS_S3_CUSTOM_DOMAIN}/{AWS_LOCATION}/"
    STATIC_ROOT = config("STATIC_ROOT")

    DEFAULT_FILE_STORAGE = "metron.storage_backends.MediaStorage"
else:
    STATICFILES_DIRS = (chartkick.js(), BASE_DIR / "static")
    STATIC_URL = "/static/"
    STATIC_ROOT = config("STATIC_ROOT")

    MEDIA_URL = "/media/"
    MEDIA_ROOT = config("MEDIA_ROOT")
    INTERNAL_IPS = ("127.0.0.1", "localhost")
    MIDDLEWARE += ("debug_toolbar.middleware.DebugToolbarMiddleware", )

    INSTALLED_APPS += ("debug_toolbar", )
Beispiel #19
0
from flask import Flask, Blueprint
from flask.ext.script import Manager, Server
from flask.ext.bootstrap import Bootstrap
from model import CheckNotifications, InitDb, DropDb
import chartkick

import authentication
import measurements

app = Flask(__name__)
app.jinja_env.line_statement_prefix = '%'

# Chartkick initialization
ck = Blueprint('ck_page',
               __name__,
               static_folder=chartkick.js(),
               static_url_path='/static')
app.register_blueprint(ck, url_prefix='/ck')
app.jinja_env.add_extension("chartkick.ext.charts")

Bootstrap(app)

app.config["SECRET_KEY"] = "ITSASECRET"

app.register_blueprint(authentication.mod)
authentication.login_manager.init_app(app)

app.register_blueprint(measurements.mod)

manager = Manager(app)
manager.add_command(
Beispiel #20
0
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = 'static/'

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    chartkick.js(),
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '66d=0ew%esg5+-i=91!9=^map^mepdt^#18ix02gn^4oqg8yu%'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    <usage>

"""

import chartkick
import eri.logging as logging

from flask import Blueprint
from .roger_plotz import app


# ----------------------------- #
#   Module Constants            #
# ----------------------------- #

logger = logging.getLogger(__name__)
logging.configure()


# ----------------------------- #
#   Main routine                #
# ----------------------------- #

# chartkick requires some additional configuration (registering the location
# of the chartkick javascript folder, as well as importing and extension)
ck = Blueprint(
    'ck_page', __name__, static_folder=chartkick.js(), static_url_path='/static'
)
app.register_blueprint(ck, url_prefix='/ck')
app.jinja_env.add_extension("chartkick.ext.charts")
Beispiel #22
0
#!flask/bin/python
from flask import Flask
import chartkick
app = Flask(__name__,static_folder=chartkick.js(), static_url_path='')
from app import views
#app.jinja_env.add_extension("chartkick.ext.charts")
Beispiel #23
0
def register_blueprints(app):
    app.register_blueprint(gw2db)
    app.register_blueprint(gw2api)
    app.register_blueprint(mainsite)
    myChartkick = Blueprint('ck_page', __name__, static_folder=chartkick.js(), static_url_path='/static')
    app.register_blueprint(myChartkick, url_prefix='/ck')
    try:
        bus = dbus.SystemBus()
        player = bus.get_object('org.mpris.MediaPlayer2.spotify', '/org/mpris/MediaPlayer2')
    except dbus.DBusException:
        APP_WITHOUT_DBUS=True
except ImportError:
    APP_WITHOUT_DBUS=True

'''
Global Variables / Utility Functions
'''

app = flask.Flask(__name__)
app.config['LOGGER_NAME'] = 'newtab'
app.debug_log_format = '%(asctime)s:%(filename)s:%(levelname)s:%(message)s'
ck = flask.Blueprint('ck_page', __name__, static_folder=chartkick.js(), static_url_path='/static')
app.register_blueprint(ck, url_prefix='/ck')
app.jinja_env.add_extension('chartkick.ext.charts')

# initialize all builtin widgets
from widgets.builtin import *
# initialize all custom widgets
from widgets.custom import *

# register your custom widgets here
available_widgets = {
        'memory': MemoryColumn,
        'load': LoadColumn,
        'links': LinksColumn,
        'music': MusicColumn,
        'cpu': CPUInfoColumn,
Beispiel #25
0
#!/usr/bin/python
from flask import Flask, render_template, request, redirect, url_for,jsonify
import sqlite3
from pprint import pprint
from datetime import datetime
import time
from geopy.geocoders import Nominatim
import chartkick

app = Flask(__name__, 
            static_folder=chartkick.js(), 
            static_url_path='/static')

app.jinja_env.add_extension("chartkick.ext.charts")
app.debug=True


def get_locations_list():
	locations = []
	db = sqlite3.connect('/home/dan/projects/uber_eta/FlaskApp/database.sqlite3')
	cursor = db.cursor()
	cursor.execute('''select location_name from locations''' )
	for row in cursor:
		locations.append(row[0])
	return locations

def get_data(location, datapoints=120):
	location_dict = {}
	location_dict['name'] = str(location)
	location_dict['datapoints'] = datapoints
	db = sqlite3.connect('/home/dan/projects/uber_eta/FlaskApp/database.sqlite3')