class TestGoogleCharts(unittest.TestCase): def setUp(self): app = Flask(__name__) app.debug = True self.charts = GoogleCharts(app) self.app = app self.client = app.test_client() def tearDown(self): self.app = None def test(self): assert "GOOGLECHARTS_VERSION" in self.app.config assert "charts_init_js" in [ x.endpoint for x in self.app.url_map.iter_rules() ] assert "drawCharts()" in self.client.get( "/charts.init.js").data.decode("utf8") def test_init_app(self): with self.assertRaises(TypeError): self.charts.init_app(1) def test_packages(self): chart = BarChart("test01_bar") self.charts.register(chart) chart = LineChart("test01_line") self.charts.register(chart) chart1 = MaterialLineChart("test01_mline") self.charts.register(chart1) assert set(json.loads(self.charts.packages())) == set( ["corechart", "line"]) def test_register(self): chart = BarChart("test") self.charts.register(chart) assert 'test' in self.charts.charts chart2 = LineChart("test") with self.assertRaises(KeyError): self.charts.register(chart2) with self.assertRaises(TypeError): self.charts.register(1) def test_template_variables(self): assert self.charts.template_variables() == {} self.charts.register(BarChart("test")) assert "charts" in self.charts.template_variables() assert "test" in self.charts.template_variables()["charts"]
def setUp(self): app = Flask(__name__) app.debug = True self.charts = GoogleCharts(app) self.app = app self.client = app.test_client()
from flask import Flask, jsonify, render_template, url_for from flask_googlecharts import GoogleCharts, BarChart, MaterialLineChart from flask_googlecharts.utils import prep_data import datetime app = Flask(__name__) charts = GoogleCharts(app) @app.route("/data") def data(): d = { "cols": [{ "id": "", "label": "syf", "pattern": "", "type": "number" }, { "id": "", "label": "Spectators", "pattern": "", "type": "number" }], "rows": [{ "c": [{ "v": 1, "f": None }, { "v": 5,
from data.users import User from data.mistakes import Mistake from data.languages import Language from data.association import Association from modules import speller, translator from collections import defaultdict from secrets import token_urlsafe from api import mistakesResources, statisticsResources, beautifierResources import json import copy import pymorphy2 app = Flask(__name__) app.config['SECRET_KEY'] = token_urlsafe(16) # Генерируем защитный ключ app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db/ortho.db' charts = GoogleCharts(app) # Инициализируем диаграммы api = Api(app) # Инициализируем API morph = pymorphy2.MorphAnalyzer() # Инициализируем модуль морфологии loginManager = LoginManager() loginManager.init_app(app) class RegisterForm(FlaskForm): ''' Форма регистрации ''' email = EmailField('Email', validators=[DataRequired()]) password = PasswordField('Password', validators=[DataRequired()]) passwordRepeat = PasswordField('Password repeat', validators=[DataRequired()]) surname = StringField('Surname', validators=[DataRequired()]) name = StringField('Name', validators=[DataRequired()])
from flask import Flask, flash, jsonify, redirect, render_template, request, session from flask_session import Session from tempfile import mkdtemp from werkzeug.exceptions import default_exceptions, HTTPException, InternalServerError from werkzeug.security import check_password_hash, generate_password_hash from datetime import datetime from flask_googlecharts import GoogleCharts from flask_googlecharts import PieChart from flask_sqlalchemy import SQLAlchemy #import commands from helpers import apology, login_required, lookup, usd # Configure application charts = GoogleCharts() app = Flask(__name__) #charts = GoogleCharts(app) charts.init_app(app) # Import pie chart and decalre in view stocks_chart = PieChart("stocks_pie_chart", options={'title': 'Portfolio'}) # Ensure templates are auto-reloaded app.config["TEMPLATES_AUTO_RELOAD"] = True # Ensure responses aren't cached @app.after_request def after_request(response):
''' Creates flask instance ''' from flask import Flask from flask_googlecharts import GoogleCharts import os webapp = Flask(__name__) charts = GoogleCharts(webapp) webapp.secret_key = os.urandom(20) from app import main from app import users from app import images
#from .main.forms import LoginForm, SearchForm, UpdateItemForm from flask_login import LoginManager, login_user, login_required, current_user, UserMixin, logout_user from bs4 import BeautifulSoup import urllib2 from flask_googlecharts import GoogleCharts, ColumnChart, BarChart, LineChart from config import config bootstrap = Bootstrap() data_db = SQLAlchemy() login_manager = LoginManager() login_manager.session_protection = 'strong' login_manager.login_view = 'main.login' charts = GoogleCharts() #bp = Blueprint('report', __name__, url_prefix='/report') def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) from .main import main as main_bp app.register_blueprint(main_bp) data_db.init_app(app) login_manager.init_app(app) bootstrap.init_app(app) charts.init_app(app)