Esempio n. 1
0
def configure_app(config):
    app.my_config = config
    app.site_title = config.get('site_title', 'DCat Search')
    app.site_slogan = config.get('site_slogan', 'data catalogue indexer')
    app.site_logo = config.get('site_logo', 'media/logo.png')
    app.site_url = config.get('site_title')
    app.site_style = config.get('site_style')
    genshi = Genshi(app)
    genshi.extensions['html'] = 'html5'
    app.debug = asbool(config.get('debug', 'false'))
    return app
Esempio n. 2
0
def create_app():
    app = Flask(__name__)
    app.register_module(pkgmod.mod)
    app.register_module(modmod.mod)

    genshi = Genshi(app)

    return app
Esempio n. 3
0
from flask import Flask, request
from flaskext.genshi import Genshi, render_response
from flask_restful import Resource, Api
#from json import dumps
from flask_jsonpify import jsonify
import json
from watson_developer_cloud import NaturalLanguageUnderstandingV1
from watson_developer_cloud.natural_language_understanding_v1 import Features, KeywordsOptions
from flask_cors import CORS

app = Flask(__name__)
app.url_map.strict_slashes = False
api = Api(app)
genshi = Genshi(app)
CORS(app)


class KeywordFinder(Resource):
    def get(self, urlin):

        natural_language_understanding = NaturalLanguageUnderstandingV1(
            version='2018-03-16',
            iam_apikey='CCtMpcdQn7LpNbxY91vvQfWKXhF8y_F9uddx3-bvJKuZ',
            url=
            'https://gateway.watsonplatform.net/natural-language-understanding/api'
        )

        response = natural_language_understanding.analyze(
            url=urlin,
            features=Features(keywords=KeywordsOptions(
                sentiment=False, emotion=False))).get_result()
Esempio n. 4
0
from flask import Flask, request, session, g, redirect, url_for, abort, flash
from flaskext.genshi import Genshi, render_response

# configuration
DATABASE = '/tmp/flaskr.db'
DEBUG = True
SECRET_KEY = 'development key'
USERNAME = '******'
PASSWORD = '******'

# create our little application :)
app = Flask(__name__)
app.config.from_object(__name__)
app.config.from_envvar('FLASKR_SETTINGS', silent=True)

genshi = Genshi(app)
genshi.extensions['html'] = 'html5'


def connect_db():
    """Returns a new connection to the database."""
    return sqlite3.connect(app.config['DATABASE'])


def init_db():
    """Creates the database tables."""
    with closing(connect_db()) as db:
        with app.open_resource('schema.sql') as f:
            db.cursor().executescript(f.read())
        db.commit()
Esempio n. 5
0
_time_expansions = dict(
    s='seconds', d='days', mo='months',
    w='weeks', wk='weeks',
    y='years', yr='years',
    m='minutes', mi='minutes',
)
_time_regex = re.compile(r'(\d+)([sd]|wk?|yr?|m[io]?)', re.I)
def parse_time_string(s):
    params = collections.defaultdict(int)
    for m in _time_regex.finditer(s):
        params[_time_expansions[m.group(2)]] += int(m.group(1))
    return relativedelta(**params)

app = Flask(__name__)
app.config.from_envvar('SHURT_SETTINGS')
genshi_wrap = Genshi(app)
genshi_wrap.extensions['html'] = 'html5'

photo_set = UploadSet('photos', extensions=IMAGES)
configure_uploads(app, [photo_set])

db = SQLAlchemy(app)

oid = OpenID(app)

def rel_generator(parent, plural, singular=None):
    singular = singular or parent.__name__.lower()
    def deco(cls):
        lower_child = cls.__name__.lower()
        child_fk = db.Column(db.Integer(), db.ForeignKey(cls.id), primary_key=True)
        generated_type = type(parent)(
Esempio n. 6
0
"""

#flask web-server
from flask import Flask, session, get_flashed_messages

#flask Genshi templates
from flaskext.genshi import render_response
from flaskext.genshi import Genshi

#flatland form processing
from flatland import Form, String
from flatland.out.genshi import setup

#initialize server, templates and callbacks
app = Flask(__name__)
genshi = Genshi(app)

app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'

@genshi.template_parsed
def callback(template):
	setup(template)

genshi.extensions['html'] = 'html5' #change default rendering mode to html5 instead of strict html4

#database/SQLAlchemy setup
from database import db_session as sess

@app.teardown_request
def shutdown_session(exception=None):
	sess.remove()
Esempio n. 7
0
from flaskext.genshi import Genshi

from vlasisku.database import Database

genshi = Genshi()
database = Database()