Exemplo n.º 1
0
def register_blueprints(app):
    app.register_blueprint(players)
    app.register_blueprint(matches)
    app.register_blueprint(history)
    app.register_blueprint(stats)
    app.register_blueprint(bannerapp)
    return app
Exemplo n.º 2
0
    def test_error_config_blueprint(self):
        views = LazyViews(blueprint, import_prefix='weird.path')
        views.add('/more-advanced',
                  'views.advanced',
                  endpoint='more_advanced')

        app.blueprints.pop('test')
        app.register_blueprint(blueprint, url_prefix='/test')

        self.assertIn('test.more_advanced', app.view_functions)

        test_app = app.test_client()
        self.assertRaises(ImportStringError,
                          test_app.get,
                          self.url('test.more_advanced'))

        views = LazyViews(blueprint, blueprint.import_name)
        views.add('/more-more-advanced',
                  'views.does_not_exist',
                  endpoint='more_more_advanced')

        app.blueprints.pop('test')
        app.register_blueprint(blueprint, url_prefix='/test')

        self.assertIn('test.more_more_advanced', app.view_functions)

        test_app = app.test_client()
        self.assertRaises(ImportStringError,
                          test_app.get,
                          self.url('test.more_more_advanced'))
Exemplo n.º 3
0
    def register_blueprint(self, blueprint, name, friendly_name, location, menu_section=None):
        assert isinstance(blueprint, ModelAdmin)
        blueprint.extra_context['navbar'] = self.navbar
        #blueprint = QuickBlueprint(name, name)
        app.register_blueprint(blueprint, url_prefix='/admin/%s' % location)

        if menu_section:
            submenu = self.navbar.get_submenu(menu_section)
            submenu.add_link(friendly_name, '/admin/%s' % location)
        else:
            self.navbar.add_link(friendly_name, '/admin/%s' % location)

        if blueprint.model._get_kind() in self.admin_views:
            raise ValueError, 'admin view for %r already registered' % (blueprint.model._get_kind(),)
        self.admin_views[blueprint.model._get_kind()] = '%s.retrieve' % name
Exemplo n.º 4
0
    def test_custom_config_blueprint(self):
        views = LazyViews(blueprint, blueprint.import_name)
        views.add('/more-advanced',
                  'views.advanced',
                  endpoint='more_advanced',
                  methods=('GET', 'POST', 'PUT'))

        # Don't forget to re-register blueprint
        app.blueprints.pop('test')
        app.register_blueprint(blueprint, url_prefix='/test')

        self.assertIn('test.more_advanced', app.view_functions)

        test_app = app.test_client()
        response = test_app.put(self.url('test.more_advanced'))
        self.assertEqual(response.status_code, 200)
        self.assertIn('Advanced test page', response.data)
Exemplo n.º 5
0
Arquivo: egrit.py Projeto: kearnh/gtui
def get_app():
    from app import app
    import api
    import git_project
    app.register_blueprint(api.api, url_prefix='/git')
    app.register_blueprint(git_project.api, url_prefix='/git/project')
    if os.name == 'nt':
        import tfs
        app.register_blueprint(tfs.api, url_prefix='/tfs')
    return app
Exemplo n.º 6
0
import os
from app import app
from app.routes.routes import blueprint

app.register_blueprint(blueprint)

production = os.environ.get("PRODUCTION", False)

if __name__ == '__main__':
    if production:
        app.run(debug=True)
    else:
        app.run(host='127.0.0.1', port=8002, debug=True)
Exemplo n.º 7
0
        if not validator.valid():
            logger.warning("Failed to validate security scan configuration")
            return

        self._target_version = app.config.get(
            "SECURITY_SCANNER_ENGINE_VERSION_TARGET", 3)
        self._analyzer = LayerAnalyzer(app.config, secscan_api)
        self._next_token = None

        interval = app.config.get("SECURITY_SCANNER_INDEXING_INTERVAL",
                                  DEFAULT_INDEXING_INTERVAL)
        self.add_operation(self._index_images, interval)

    def _index_images(self):
        self._next_token = index_images(self._target_version, self._analyzer,
                                        self._next_token)


if __name__ == "__main__":
    app.register_blueprint(v2_bp, url_prefix="/v2")

    if not features.SECURITY_SCANNER:
        logger.debug("Security scanner disabled; skipping SecurityWorker")
        while True:
            time.sleep(100000)

    logging.config.fileConfig(logfile_path(debug=False),
                              disable_existing_loggers=False)
    worker = SecurityWorker()
    worker.start()
Exemplo n.º 8
0
from flask import render_template
from flask import request
from flask import url_for
from flask import g

from flask.ext.security import current_user

from app import app
from app.models import Project

from . import patch
from . import project
from . import user

app.register_blueprint(project.bp)
app.register_blueprint(patch.bp)
app.register_blueprint(user.bp)


def redirect_url(default='index'):
    return request.args.get('next') or request.referrer or url_for(default)

@app.before_request
def before_request():
    g.user = current_user

@app.route('/')
@app.route('/index')
def index():
    return render_template('index.html',
                           title="Homepage",
Exemplo n.º 9
0
__author__ = 'stepan'

from app import app
from models import db
from main_page import mainpage
from report import report
from puppies import puppies
from shelters import shelters
from puppy_profile import puppy_profile
from login_page import login_page


app.register_blueprint(mainpage)
app.register_blueprint(report)
app.register_blueprint(puppies)
app.register_blueprint(shelters)
app.register_blueprint(puppy_profile)
app.register_blueprint(login_page)

def create_tables():
    return db.create_all()

if __name__ == '__main__':
    app.run(port=5001)
Exemplo n.º 10
0
    consumes:
      - multipart/form-data
      - application/x-www-form-urlencoded

    definitions:
      - schema:
          id: PhotoInfo
          type: object
          required:
            - faces
          properties:
            faces:
              description: an array of FaceInfo objects found in this image
              schema:
                type: array
                items:
                  $ref: '#/definitions/FaceInfo'
            annotated_image:
              type: string
              format: byte
              description: base64 encoded annotated image
    '''
    image_rgb, image_gray, annotated_rgb = obtain_images(request)
    photoinfo = build_PhotoInfo(image_gray, annotated_rgb)
    return jsonify(photoinfo)


from app import app
app.register_blueprint(blueprint, url_prefix='/'+VERSION_STR)
Exemplo n.º 11
0
@login_required
def index():
    if current_user.rank == 1:
        return redirect(url_for('driver_module.orders'))
    return redirect(url_for('order_module.list'))


@app.route('/admin/toggle_help')
@login_required
def toggle_help():
    response = make_response(redirect(request.args.get('next') or url_for('index')))
    if request.cookies.get('help-cont') is None or request.cookies.get('help-cont') == '':
        response.set_cookie('help-cont', 'remove', time() + (2 * 365 * 24 * 60 * 60))
    else:
        response.set_cookie('help-cont', '', time() + (2 * 365 * 24 * 60 * 60))
    return response

app.register_blueprint(user_module, url_prefix='/admin/user')
app.register_blueprint(shop_module, url_prefix='/admin/shop')
app.register_blueprint(category_module, url_prefix='/admin/category')
app.register_blueprint(product_module, url_prefix='/admin/product')
app.register_blueprint(order_module, url_prefix='/admin/order')
app.register_blueprint(contacts_module, url_prefix='/admin/contacts')
app.register_blueprint(settings_module, url_prefix='/admin/settings')

app.register_blueprint(driver_module, url_prefix='/driver')

app.register_blueprint(upload_module, url_prefix='/admin/upload')

app.register_blueprint(market_module, url_prefix='')
Exemplo n.º 12
0
# -*- coding:utf-8 -*-
from app import app, login_manager
from flask.ext.admin import Admin
from flask.ext.admin.contrib.fileadmin import FileAdmin
from views import light_cms
from wc import wc
from admin_views import UserView, IndexView, GeneralView
from models import User, Image, Gallery
import settings


login_manager.init_app(app)

app.register_blueprint(light_cms)
app.register_blueprint(wc)

admin = Admin(app, name="{}后台管理".format(settings.SITE_NAME), index_view=IndexView(endpoint='admin'))
admin.add_view(UserView(User, name='用户'))
admin.add_view(FileAdmin(settings.UPLOAD_FOLDER, settings.UPLOAD_URL, name='媒体文件'))
admin.add_view(GeneralView(Image, name='图片'))
admin.add_view(GeneralView(Gallery, name='图册'))
Exemplo n.º 13
0
# -*- coding: utf8 -*-

from app import app
import index

# register the Category module
from categories.index import CategoriesView  # noqa
CategoriesView.register(app)

# register the Post module
from posts.index import PostsView  # noqa
PostsView.register(app)

# register the User module
from users.index import UsersView  # noqa
UsersView.register(app)

# register the sessions module blueprint
from sessions.index import mod as sessionsModule  # noqa
app.register_blueprint(sessionsModule, url_prefix='/members')
Exemplo n.º 14
0
from routes.expression import expression
from routes.entity import entity
from routes.regex import regex
from routes.synonym import synonym
from routes.variant import variant
from routes.setting import setting
from routes.response import response
from routes.parameter import parameter
from routes.log import log
from routes.nlu_router import nlu_router
from routes.middleware import middleware
from routes.rasa_events import rasa_events
from routes.messages import messages
from routes.auth import auth

app.register_blueprint(action)
app.register_blueprint(intent)
app.register_blueprint(agent)
app.register_blueprint(expression)
app.register_blueprint(variant)
app.register_blueprint(entity)
app.register_blueprint(regex)
app.register_blueprint(synonym)
app.register_blueprint(setting)
app.register_blueprint(response)
app.register_blueprint(parameter)
app.register_blueprint(log)
app.register_blueprint(nlu_router)
app.register_blueprint(middleware)
app.register_blueprint(rasa_events)
app.register_blueprint(messages)
Exemplo n.º 15
0
from flask_debugtoolbar import DebugToolbarExtension
from app.models import db
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
import os
import re
from config import BASEDIR
from app.models import User

app.config['SECRET_KEY'] = 'odinhj_123456'
app.config['DEBUG_TB_INTERCEPT_REDIRECTS '] = False
app.config['UPLOAD_FOLDER'] = os.path.join(BASEDIR, 'app', 'static', 'dist',
                                           'img')
Bootstrap(app)
debugs = DebugToolbarExtension(app)
app.register_blueprint(cms_blueprint, url_prefix="/cms")
app.register_blueprint(student_blueprint, url_prefix="/student")

Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)


@manager.command
def create_user():
    username = input("uername:")
    password = input('password:'******'two password:'******'email:')
    phone = input('phone:')
    if password == password2 and re.match(r'[0-9a-zA-Z_]{0,19}@qq.com',
Exemplo n.º 16
0
import unittest
import endpoints.decorated
import json

from app import app
from util.names import parse_namespace_repository
from initdb import setup_database_for_testing, finished_database_for_testing
from specs import build_v1_index_specs

from endpoints.v1 import v1_bp

app.register_blueprint(v1_bp, url_prefix="/v1")

NO_ACCESS_USER = "******"
READ_ACCESS_USER = "******"
CREATOR_ACCESS_USER = "******"
ADMIN_ACCESS_USER = "******"


class EndpointTestCase(unittest.TestCase):
    def setUp(self):
        setup_database_for_testing(self)

    def tearDown(self):
        finished_database_for_testing(self)


class _SpecTestBuilder(type):
    @staticmethod
    def _test_generator(url, expected_status, open_kwargs, session_var_list):
        def test(self):
Exemplo n.º 17
0
from app import app, db

from admin.routes import admin

app.register_blueprint(admin)
from app import app
from flask_cors import CORS

cors = CORS(app, resources={r"/api/*": {"origins": "*"}})

## API Routes ##
from myapp_api.blueprints.users.views import users_api_blueprint
from myapp_api.blueprints.sessions.views import sessions_api_blueprint

app.register_blueprint(users_api_blueprint, url_prefix='/api/v1/users')
app.register_blueprint(sessions_api_blueprint, url_prefix='/api/v1/sessions')
Exemplo n.º 19
0
# -*- coding: utf-8 -*-

from app import app, db
import admin  # This line is new, plimport models
import models
import views
import api

from urllib.parse import urljoin
from flask import request, url_for
from werkzeug.contrib.atom import AtomFeed
from models import Entry

from entries.blueprint import entries

app.register_blueprint(entries, url_prefix="/entries")
from snippets.blueprint import snippets

app.register_blueprint(snippets, url_prefix="/snippets")


@app.route("/latest.atom")
def recent_feed():
    feed = AtomFeed("Latest Blog Posts", feed_url=request.url, url=request.url_root, author=request.url_root)
    entries = (
        Entry.query.filter(Entry.status == Entry.STATUS_PUBLIC).order_by(Entry.created_timestamp.desc()).limit(15).all()
    )
    for entry in entries:
        feed.add(
            entry.title,
            entry.body,
from instagram_web.blueprints.session.routes import session_blueprint
from instagram_web.blueprints.images.routes import images_blueprint
from instagram_web.blueprints.payments.routes import payments_blueprint
from instagram_web.blueprints.follow.routes import follow_blueprint
from flask_assets import Environment, Bundle
from .util.assets import bundles
from models.user import User
from flask_login import login_required
from instagram_web.helpers.google_oauth import oauth
import config

assets = Environment(app)
assets.register(bundles)
oauth.init_app(app)

app.register_blueprint(users_blueprint, url_prefix="/users")
app.register_blueprint(session_blueprint, url_prefix="/session")
app.register_blueprint(images_blueprint, url_prefix="/images")
app.register_blueprint(payments_blueprint, url_prefix="/payments")
app.register_blueprint(follow_blueprint, url_prefix="/follow")


@app.errorhandler(500)
def page_not_found(e):
    return render_template('500.html'), 500


@app.errorhandler(404)
def page_not_found(e):
    if 'user_id' in session:
        current_user = User.get_by_id(session['user_id'])
Exemplo n.º 21
0
@admin_blueprint.route('search/')
@decor.admin_required
def admin_search():
    query = flask.request.args.get('q', '').strip()

    if query:
        results = BaseModel.search_get_index().search(query)
        number_found = results.number_found
    else:
        results = None
        number_found = None

    return flask.render_template(
        'search.html',
        query=query,
        get_from_search_doc=get_from_search_doc,
        navbar=admin_area.navbar,
        number_found=number_found,
        results=results)


#
# Maps model to admin view

from app import app

app.register_blueprint(admin_blueprint, url_prefix='/admin/')

from apps.admin.register import admin_area
Exemplo n.º 22
0
        help="The port to declare to run the server, default is 5000")
    return parser.parse_args()


if __name__ == "__main__":
    args = parse_arguments()
    server = "127.0.0.1"
    port = "5000"
    if args.server:
        server = args.server
    if args.port:
        port = args.port
    #Configure the app
    app.config['DEBUG'] = True
    app.config['SWAGGER_URL'] = '/api/docs'
    app.config['DATA_SWAGGER'] = 'http://' + server + ':' + port + '/swagger'
    app.config['BUNDLE_ERRORS'] = True
    # Define the blueprint of the API
    swaggerui_blueprint = get_swaggerui_blueprint(
        app.config[
            'SWAGGER_URL'],  # Swagger UI static files will be mapped to '{SWAGGER_URL}/dist/'
        app.config['DATA_SWAGGER'],
        config={  # Swagger UI config overrides
            'app_name': config.API_NAME
        },
    )
    app.register_blueprint(swaggerui_blueprint,
                           url_prefix=app.config['SWAGGER_URL'])
    #Run it
    app.run(host=server, port=port)
Exemplo n.º 23
0
from main_views import main


import os, sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'app'))
from app import app

app.register_blueprint(main)

Exemplo n.º 24
0
from flask_api.blueprints.api_comment import comments_api_blueprint
from flask_api.blueprints.api_equipment import equipments_api_blueprint
from flask_api.blueprints.api_ingredient import ingredients_api_blueprint
from flask_api.blueprints.api_step import steps_api_blueprint
from flask_api.blueprints.api_tag import tags_api_blueprint

import flask_api.blueprints.relations.api_like
import flask_api.blueprints.relations.api_recipe_equipment
import flask_api.blueprints.relations.api_recipe_ingredient
import flask_api.blueprints.relations.api_recipe_tag
import flask_api.blueprints.relations.api_step_equipment
import flask_api.blueprints.relations.api_step_ingredient
import flask_api.blueprints.relations.api_subscription
import flask_api.blueprints.relations.api_recipe_step

cors = CORS(app, resources={r"/api/*": {"origins": "*"}})

app.register_blueprint(auth_api_blueprint, url_prefix='/api/auth')
app.register_blueprint(users_api_blueprint, url_prefix='/api/users')
app.register_blueprint(comments_api_blueprint, url_prefix='/api/comments')
app.register_blueprint(equipments_api_blueprint, url_prefix='/api/equipments')
app.register_blueprint(ingredients_api_blueprint, url_prefix='/api/ingredients')
app.register_blueprint(recipes_api_blueprint, url_prefix='/api/recipes')
app.register_blueprint(steps_api_blueprint, url_prefix='/api/steps')
app.register_blueprint(tags_api_blueprint, url_prefix='/api/tags')





Exemplo n.º 25
0
from flask import Blueprint, g
from app import app

blueprint = Blueprint('tenants', __name__, template_folder='templates')

import controllers
import models

app.register_blueprint(blueprint)

@app.context_processor
def inject_tenant():
    """
    Adds user and auth information to flask templates
    """
    return dict(
        current_tenant_membership=g.current_tenant_membership,
        current_tenant=g.current_tenant
    )
Exemplo n.º 26
0
from app import app
from flask import render_template
from project_web.blueprints.teachers.views import teachers_blueprint
from project_web.blueprints.students.views import students_blueprint
from project_web.blueprints.sessions.views import sessions_blueprint
from project_web.blueprints.surveys.views import surveys_blueprint
from flask_assets import Environment, Bundle
from .util.assets import bundles

assets = Environment(app)
assets.register(bundles)

app.register_blueprint(teachers_blueprint, url_prefix="/teachers")
app.register_blueprint(students_blueprint, url_prefix="/students")
app.register_blueprint(sessions_blueprint, url_prefix="/sessions")
app.register_blueprint(surveys_blueprint, url_prefix="/surveys")


@app.errorhandler(500)
def internal_server_error(e):
    return render_template('500.html'), 500


@app.route("/")
def home():
    return render_template('home.html')


@app.route("/contact")
def contact():
    return render_template('contact_us.html')
Exemplo n.º 27
0
import os

# Import the main Flask app
from app import app

# Get Blueprint Apps
from notes import notes_app
from auth import auth_flask_login
from rooms import rooms

# Register Blueprints
app.register_blueprint(notes_app)
app.register_blueprint(auth_flask_login)
app.register_blueprint(rooms)

# start the server
if __name__ == "__main__":
	port = int(os.environ.get('PORT', 5000)) # locally PORT 5000, Heroku will assign its own port
	app.run(host='0.0.0.0', port=port)
Exemplo n.º 28
0
from app import app

from views import main
from auth import auth

app.register_blueprint(main)
app.register_blueprint(auth)

if __name__ == '__main__':
    app.run(port=3030, debug=True)
Exemplo n.º 29
0
    :copyright: and :license: see TOPMATTER.
"""

from flask import (render_template)
from app import app
from app.users.views import mod as usersModule
from app.unity.views import mod as unityModule


@app.route('/')
@app.route('/root')
@app.route('/index')
def index():
    return render_template("index.html", pageTitle="root")


app.register_blueprint(usersModule)
app.register_blueprint(unityModule)


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


@app.errorhandler(500)
def internal_server_error(error):
    return render_template("error500.html",
                           pageTitle="error500"), 500
Exemplo n.º 30
0
def register_routes():
    app.register_blueprint(api)
Exemplo n.º 31
0
from app import app
from flask_cors import CORS
from app import csrf

cors = CORS(app, resources={r"/api/*": {"origins": "*"}})

## API Routes ##
from instagram_api.blueprints.users.views import users_api_blueprint

app.register_blueprint(users_api_blueprint, url_prefix='/api/v1/users')

from instagram_api.blueprints.images.views import images_api_blueprint

app.register_blueprint(images_api_blueprint, url_prefix='/api/v1/images')
csrf.exempt(images_api_blueprint)

from instagram_api.blueprints.login.views import login_api_blueprint

app.register_blueprint(login_api_blueprint, url_prefix='/api/v1/auth')
Exemplo n.º 32
0
# TODO: dodać baze z uczniami (ich id jako klucz obcy)
# * uczeń na dostęp jedynie do swoich oceny
# * przeglądanie planu lekcji
#! dodanie planu lekcji zmiana co 24h
# TODO: po zalogowaniu losowane są godziny lekcyjne (6) oraz nauczyciele dla klas (bez powtórzeń)
#! przebudować dodawanie nauczycieli
# TODO: dodać wybór nauczanego przedmiotu
# TODO: dodać wybór jako wychowawca
#! przebudować doadwanie ocen
# TODO: dodać pole wyboru daty
#! zmienić adres strony
# TODO: zmienić adres ip na mnemoniczny
#! pozbyć się testu
# TODO: wyrzucić test do innego projektu
# TODO: dodać adres ip oraz mnemoniczny
#! przebudować wygląd strony
# TODO: zmienić layout
#! naprawa systemu usuwania ocen
# TODO: naprawić system usuwania ocen (zrobić button w nim input dać niewidzalny test)
# ? dodać najnowsze aktualizacje ocen

app.permanent_session_lifetime = timedelta(minutes=20)
admin = Admin(app)
app.register_blueprint(dodaj, url_prefix="/dodaj")
app.register_blueprint(test, url_prefix="/test")
app.register_blueprint(uczniowie, url_prefix="/uczniowie")

if __name__ == "__main__":
    app.run(debug=True)
    db.create_all()
Exemplo n.º 33
0
from app import app
from app import db
import view

from posts.blueprint import posts
from contact.blueprint import contact
from services.blueprint import services
from registration.blueprint import registration

app.register_blueprint(posts, url_prefix='/blog')
app.register_blueprint(contact, url_prefix='/contact')
app.register_blueprint(services, url_prefix='/services')
app.register_blueprint(registration, url_prefix='/signup')

if __name__ == '__main__':
    app.run()
Exemplo n.º 34
0
import os
from flask import abort
from app import app
from controllers import auth
from controllers import venues

app.register_blueprint(auth.router, url_prefix='/api')
app.register_blueprint(venues.router, url_prefix='/api/')


@app.route('/')
@app.route('/<path:path>')
def catch_all(path='index.html'):

    if os.path.isfile('public/' + path):
        return app.send_static_file(path)

    return abort(404)
Exemplo n.º 35
0
from app import app,db,socketio
from models import Clicker,get_last_click_and_clicker,get_leaders
from datetime import datetime
from flask import render_template,request,redirect,flash
from form import ClickForm
from flask.ext.socketio import emit
from api import cats_api

app.register_blueprint(cats_api)  # connects route configration in api.py

@app.route('/')
@app.route('/<int:page>')
def index(page=1):
    form = ClickForm()
    last_click, last_clicker = get_last_click_and_clicker()
    delta = datetime.utcnow() - last_click
    leaders = get_leaders(page)
    return render_template('index.html', **locals())

@socketio.on('connected')
def confirm_connection(message):
    last_click,_ = get_last_click_and_clicker()
    emit('server confirmation',{'last':last_click})

@socketio.on('collective update')
def handler(message):
    pass


@app.route('/click', methods=['POST'])
def click_thebutton():
Exemplo n.º 36
0
from app import app
from app import db
import view

from movies.blueprint import movies
from movies import urls

app.register_blueprint(movies, url_prefix = '/movies')

if __name__ == '__main__':
    app.run()
Exemplo n.º 37
0
from app import app

from controllers.spiders import spiders_bp
from controllers.update_spider import updatespider_bp

app.register_blueprint(spiders_bp)
app.register_blueprint(updatespider_bp)
Exemplo n.º 38
0
from app import app, socketio
from apps.foodApi.urls import api_urls
from apps.foodWeb.urls import web_urls

app.register_blueprint(api_urls)
app.register_blueprint(web_urls)

if __name__ == '__main__':
    socketio.run(app, debug=True)
Exemplo n.º 39
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-


# Import the main Flask app
from app import app
import routes, error_handlers

# Register Blueprint modules
app.register_blueprint(routes.blueprint)
app.register_blueprint(error_handlers.blueprint)

# Run server
if __name__ == '__main__':
	app.run(port=5000, debug=True)
Exemplo n.º 40
0
from app import app
import view
from posts.blueprint import posts
from models import *

app.register_blueprint(posts, url_prefix='/blog')

if __name__ == '__main__':

    app.run()
Exemplo n.º 41
0
from app import app
from flask_rum.main import rum
#import flask_rum.rum_config as rum_config
#app.config.from_object(rum_config)
app.config.THEME_FOLDER='rum/banana/'
app.config.PROJECT_TITLE = '[Flask-Rum]'
app.config.TEMPLATE_DEFAULTS = {
'nav': 'site/blocks/rum_nav.html',
'footer': 'site/blocks/rum_footer.html'
}
app.register_blueprint(rum)
Exemplo n.º 42
0
from app import app
from flask_cors import CORS

cors = CORS(app, resources={r"/api/*": {"origins": "*"}})

## API Routes ##
from ezpark_api.blueprints.users.views import users_api_blueprint
from ezpark_api.blueprints.features.views import features_api_blueprint

app.register_blueprint(users_api_blueprint, url_prefix='/api/v1/users')
app.register_blueprint(features_api_blueprint, url_prefix='/api/v1/features')
Exemplo n.º 43
0
import admin
import models
import views
from app import app, db
from customers.blueprint import customers
from entries.blueprint import entries

app.register_blueprint(entries, url_prefix='/entries')
app.register_blueprint(customers, url_prefix='/customers')

if __name__ == '__main__':
    app.run()
Exemplo n.º 44
0
# -*- coding: utf-8 -*-
# Copyright (c) 2017 - zhengbin <*****@*****.**>
# Create Date: 2018/7/27 20:37
""" 主入口 """

from flask import Flask
from app.main.views import main
from app.leaf.leaf_views import leaf
from app.book.book_views import book
from app import app

app.register_blueprint(main, url_prefix='/')
app.register_blueprint(leaf, url_prefix='/leaf')
app.register_blueprint(book, url_prefix='/book')

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True)
Exemplo n.º 45
0
from app import app, db
import models
import views

from asn.blueprint import asn
app.register_blueprint(asn, url_prefix='/asn')

if __name__ == '__main__':
    app.run()
Exemplo n.º 46
0
@roles_accepted('admin')  # Limits access to users with the 'admin' role
def admin_page():
    if current_user.is_authenticated:
        return redirect(url_for('core.user_page'))
    return render_template('core/admin_page.html')


@core_blueprint.route('user/profile', methods=['GET', 'POST'])
@login_required
def user_profile_page():
    # Initialize form
    form = UserProfileForm(request.form, current_user)

    # Process valid POST
    if request.method == 'POST' and form.validate():
        # Copy form fields to user_profile fields
        form.populate_obj(current_user)

        # Save user_profile
        db.session.commit()

        # Redirect to home page
        return redirect(url_for('core.home_page'))

    # Process GET or invalid POST
    return render_template('core/user_profile_page.html', form=form)


# Register blueprint
app.register_blueprint(core_blueprint)
Exemplo n.º 47
0
Arquivo: views.py Projeto: zeuscp/zcp
from flask import render_template, flash, redirect, session, url_for
from app import app, db, modules
from models import User
#from app.modules.domain.view import mod as domain
#from app.modules.database.view import mod as database
from app.modules.user.view import mod as user
#from app.modules.system.main import System
from app.modules.overview.view import mod as overview

app.register_blueprint(overview)
app.register_blueprint(user)
#app.register_blueprint(database)

@app.errorhandler(404)
def page_not_found(e):
    return render_template("sb-admin/404.html"), 404
Exemplo n.º 48
0
from controllers.waypoint_controller import waypoint_controller
from controllers.incidence_controller import incidence_controller
from controllers.municipality_controller import municipality_controller

from flask_cors import CORS

import logging
from werkzeug.exceptions import InternalServerError, NotFound

logger = logging.getLogger(__name__)

server_config = ConfigManager.get_instance().get_server_config()
application_root = ConfigManager.get_instance().get_application_root()

app.register_blueprint(waypoint_controller, url_prefix=application_root)
app.register_blueprint(incidence_controller, url_prefix=application_root)
app.register_blueprint(municipality_controller, url_prefix=application_root)


@app.errorhandler(Exception)
def handle_excpetion(e):
    if isinstance(e, NotFound):
        # Not found exception also contains automatic calls from browsers, e.g. to /favicon.ico
        logger.debug('A NotFound exception occurred.', exc_info=e)
        return e
    elif isinstance(e, redis.exceptions.ConnectionError):
        logger.critical(
            'Could not connect to redis server. Make sure it is started!',
            exc_info=e)
        return InternalServerError(
Exemplo n.º 49
0
# coding=utf-8
from flask import render_template
from app import app


from home.home import blueprint as hom_blueprint
from aggregator.aggregator import blueprint as agg_blueprint
from environment.environment import blueprint as env_blueprint
from nodes.nodes import blueprint as nod_blueprint
from server.server import blueprint as ser_blueprint
from settings.settings import blueprint as set_blueprint
from creatures.creatures import blueprint as cre_blueprint

app.register_blueprint(blueprint=hom_blueprint)
app.register_blueprint(blueprint=agg_blueprint)
app.register_blueprint(blueprint=env_blueprint)
app.register_blueprint(blueprint=nod_blueprint)
app.register_blueprint(blueprint=ser_blueprint)
app.register_blueprint(blueprint=set_blueprint)
app.register_blueprint(blueprint=cre_blueprint)

__author__ = 'Lesko'


# Documentation is like sex.
# When it's good, it's very good.
# When it's bad, it's better than nothing.
# When it lies to you, it may be a while before you realize something's wrong.

# basic_auth = BasicAuth(app)
Exemplo n.º 50
0
from app import app
from app import db
import view
from posts.blueprint import posts

app.register_blueprint(posts,
                       url_prefix='/blog')  # Регестрируем созданный blueprint

if __name__ == '__main__':  # MAIN, запуск приложения
    app.run(debug=True, host='0.0.0.0')
Exemplo n.º 51
0
from app import app
from app.user_api.user_app import app as user_app
from app.forum_api.forum_app import app as forum_app
from app.thread_api.thread_app import app as thread_app
from app.post_api.post_app import app as post_app

API_PREFIX = "/db/api"

app.register_blueprint(user_app, url_prefix=API_PREFIX + '/user')
app.register_blueprint(forum_app, url_prefix=API_PREFIX + '/forum')
app.register_blueprint(thread_app, url_prefix=API_PREFIX + '/thread')
app.register_blueprint(post_app, url_prefix=API_PREFIX + '/post')


app.run(host='0.0.0.0', port=8000, debug=False)
Exemplo n.º 52
0
from flask_restless.views import ValidationError

from app import api_manager, app
from src.main.dto.email_log import exclude_columns
from src.main.http.cros_headers import add_cors_headers
from src.main.model.email_log import EmailLog as EmailLogModel
from src.main.service.email_log import send_email as send_email_service
from src.main.security.authentication import auth_func
from src.main.security.authorization import role_first_level, role_second_level

email_log_api = api_manager.create_api_blueprint(
    EmailLogModel,
    collection_name='email-log',
    methods=['GET', 'POST'],
    exclude_columns=exclude_columns(),
    validation_exceptions=[ValidationError],
    allow_functions=True,
    preprocessors=dict(GET_SINGLE=[auth_func, role_first_level],
                       GET_MANY=[auth_func, role_first_level],
                       POST=[auth_func, role_second_level]),
    postprocessors=dict(POST=[send_email_service]))

email_log_api.after_request(add_cors_headers)
app.register_blueprint(email_log_api)
Exemplo n.º 53
0
from app import app
from app import views

if __name__ == '__main__':
    app.register_blueprint(views.mod)
    app.run(host="0.0.0.0", port=5000, debug=True)
Exemplo n.º 54
0
from app import app
from flask import render_template
from phonebook_web.blueprints.users.views import users_blueprint
from flask_assets import Environment, Bundle
from .util.assets import bundles

assets = Environment(app)
assets.register(bundles)

app.register_blueprint(users_blueprint, url_prefix="/users")


@app.errorhandler(500)
def internal_server_error(e):
    return render_template('500.html'), 500


@app.route("/")
def home():
    return render_template('home.html')
Exemplo n.º 55
0
@core_blueprint.route('admin')
@roles_accepted('admin')  # Limits access to users with the 'admin' role
def admin_page():
    return render_template('core/admin_page.html')


@core_blueprint.route('user/profile', methods=['GET', 'POST'])
@login_required
def user_profile_page():
    # Initialize form
    form = UserProfileForm(request.form, current_user)

    # Process valid POST
    if request.method == 'POST' and form.validate():
        # Copy form fields to user_profile fields
        form.populate_obj(current_user)

        # Save user_profile
        db.session.commit()

        # Redirect to home page
        return redirect(url_for('core.home_page'))

    # Process GET or invalid POST
    return render_template('core/user_profile_page.html',
                           form=form)


# Register blueprint
app.register_blueprint(core_blueprint)
Exemplo n.º 56
0
from app import app
from app import db

from ads.blueprint import ads

import view

app.register_blueprint(ads, url_prefix="/board")

if __name__ == "__main__":
    app.run()
Exemplo n.º 57
0
            print e
            db.session.rollback()
            id = db_name.query.get(relationship)
        try:
            # Get ID of the last insert
            details = {}
            # set relationship
            append = db_join(**d)
            db.session.add(append)
            db.session.commit()
        except Exception, e:
            print e
            db.session.rollback()
            abort(500)

app.register_blueprint(users)
app.register_blueprint(domains)
app.register_blueprint(logging)
app.register_blueprint(overview)

#@app.route('/')
#def index():
#    return "hello world"

@app.errorhandler(400)
def bad_request(error):
    db.session.rollback()
    return make_response(jsonify({'error':'Bad Request'}), 400)

@app.errorhandler(404)
def not_found(error):
Exemplo n.º 58
0
            flash('Неверное имя пользователя или пароль')
            return redirect(url_for('login'))
        login_user(user, remember=form.remember_me.data)
        return redirect(url_for('mytask'))
    return render_template('login.html', title='Логин', form=form)


@app.route('/register', methods=['GET', 'POST'])
def register():
    if current_user.is_authenticated:
        return redirect(url_for('mytask'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = Users(username=form.username.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Поздравляю теперь вы зарегистрированы! Войдите в систему')
        return redirect(url_for('login'))
    return render_template('register.html', title='Регистрация', form=form)


@app.route('/logout')
def logout():
    logout_user()
    return redirect(url_for('index'))


from .main import main as main_blueprint
app.register_blueprint(main_blueprint)
Exemplo n.º 59
0
@bp.route("/<path:path>/")
def main2(groupname, path):
    if url_exists(path):
        if request.query_string:
            path = path + '/?' + request.query_string
        if current_user.is_authenticated:
            save_url(path, groupname)
        else:
            session['url'] = path
            session['groupname'] = groupname
            return redirect(url_for('login'))

    return redirect(url_for('main'))

# Register the blueprint into the application
app.register_blueprint(bp)


@app.route('/register/', methods=['GET', 'POST'])
def register():
    form = RegistrationForm(request.form)
    if request.method == 'POST' and form.validate_on_submit():
        user = User(email=form.email.data, password=form.password.data)
        db.session.add(user)
        db.session.commit()
        login_user(user, remember=True)
        return redirect(url_for('main'))
    return render_template('register.jade', form=form)


@app.route('/restore_password/', methods=['GET', 'POST'])
Exemplo n.º 60
0
# coding:utf8

from app import app

from app.modules.home import home as home_blueprint
from app.modules.userManage import userManage as userManage_blueprint
from app.modules.api import api as api_blueprint
from app.modules.job import job as job_blueprint
from app.modules.model import model as model_blueprint
from app.modules.list import list as list_blueprint
from app.modules.data import data as data_blueprint

app.register_blueprint(home_blueprint)
app.register_blueprint(userManage_blueprint, url_prefix="/userManage")
app.register_blueprint(api_blueprint, url_prefix="/api")
app.register_blueprint(job_blueprint, url_prefix="/job")
app.register_blueprint(model_blueprint, url_prefix="/model")
app.register_blueprint(list_blueprint, url_prefix="/list")
app.register_blueprint(data_blueprint, url_prefix="/data")

if __name__ == "__main__":
    # app.run(host='10.108.211.136', port=15050)
    app.run(host='localhost', port=15050)