コード例 #1
0
def main():
    owt = Blueprint('owt',
                    'owt',
                    template_folder='owt_templates',
                    static_folder='static')
    init_owt_routes(owt, application.shepherd)
    application.register_blueprint(owt)
コード例 #2
0
def runserver():
    if not os.path.exists('database.db'):
        db_reset()
    application.config['HOST'] = 'localhost:5000/'
    application.register_blueprint(routes.api, url_prefix='/')
    application.run(host='localhost', port=5000, debug=True)
コード例 #3
0
from app import application, db
from app.blueprint.ocrreader.views import ocr_reader
from app.blueprint.ocrreader.models import RecognitionResult
from config import ddl, port_number
from constants import DDLMode
from flask_cors import CORS

application.register_blueprint(ocr_reader, url_prefix='/ocrreaders')

if ddl is DDLMode.CREATE:
    db.create_all()
    db.session.commit()
elif ddl is DDLMode.CREATE_DROP:
    db.drop_all()
    db.create_all()
    db.session.commit()

CORS(application)
application.run(port=port_number)
コード例 #4
0
from flask import Flask, render_template
from app import application

from app.admin import admin as admin_blueprint
application.register_blueprint(admin_blueprint, url_prefix="/admin")


@application.route('/')
def homepage():
    """
    Render the homepage template on the / route
    """
    return render_template('page/home/index.html', title="Welcome")


@application.errorhandler(404)
def page_not_found(error):
    return render_template('page/errors/404.html', title='Page Not Found'), 404
コード例 #5
0
from flask import Blueprint
from flask_restful import Api

from app import application
from .resources import Users, Roles, Auth, Protected

# register blueprint
api_bp = Blueprint('api', __name__)

# create routes
api = Api(api_bp, default_mediatype="application/json")

# users
api.add_resource(Users.UsersAPI, '/users')
api.add_resource(Users.SingleUserAPI, '/users/<int:user_id>')
api.add_resource(Users.UserRoleAPI, '/users/<int:user_id>/roles')
# roles
api.add_resource(Roles.RolesAPI, '/roles')
api.add_resource(Roles.SingleRoleAPI, '/roles/<int:role_id>')
# authentication
api.add_resource(Auth.UserLogin, '/login')
api.add_resource(Auth.TokenRefresh, '/login/refresh')
api.add_resource(Auth.UserLogoutAccess, '/logout/access')
api.add_resource(Auth.UserLogoutRefresh, '/logout/refresh')
# protected resource
api.add_resource(Protected.ProtectedResource, '/protected')
api.add_resource(Protected.ProtectedAdminResource, '/protected/admin')
# register the blueprint
application.register_blueprint(api_bp, url_prefix='/api')
コード例 #6
0
ファイル: main.py プロジェクト: singh-prashant/blog
from app import application as app
import admin
import api
from app import db
import models
import views

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

if __name__ == "__main__":
    app.run()
コード例 #7
0
import sys
import os

from app import application
from app.api import routes
from config import MYSQL_USERNAME, MYSQL_PASSWORD, SERVER_IP, MYSQL_PORT, MYSQL_DB_NAME

INTERP = os.path.expanduser('path/to/venv/')
if sys.executable != INTERP:
    os.execl(INTERP, INTERP, *sys.argv)
sys.path.append(os.getcwd())

application.config['HOST'] = ''  # fill it
application.config['SQLALCHEMY_DATABASE_URI'] = ''.join([
    'mysql+pymysql://', MYSQL_USERNAME, ':', MYSQL_PASSWORD, '@', SERVER_IP,
    ':', MYSQL_PORT, '/', MYSQL_DB_NAME
])
application.register_blueprint(routes.api, url_prefix='/')

if __name__ == '__main__':
    application.run(host='0.0.0.0')
コード例 #8
0
ファイル: application.py プロジェクト: zhangfaquan/Achoo
# api
from app.api.api import Prediction, Admin

# models
from app.models.models import User

# app
from app import application

# config
from app.config import Config

sslify = SSLify(application)

application.register_blueprint(views_blueprints)
login_manager = LoginManager(application)
login_manager.login_view = 'main.login'

@application.before_request
def inject_globals():
    with application.app_context():
        session['VERSION'] = Config.VERSION
        session['MSG'] = Config.MSG
    return None

@login_manager.user_loader
# @application.before_request
def load_user(user_id):
    return User.query.get(user_id)
コード例 #9
0
ファイル: routers.py プロジェクト: Ambition-J/flask-template
# !/use/bin/python3
# _*_ coding:utf-8 _*_
# __author__ : __ajiang__
# 2020/7/11

# 路由蓝图集合
from app import application
from web.controllers import route_api

application.register_blueprint(route_api, url_prefix='/api')