def register_blueprint(): app.config.from_object('{}.{}.{}'.format(APP_NAME, 'config', 'swagger')) assigner = RedprintAssigner(app=app, rp_api_list=app.config['ALL_RP_API_LIST'], api_path='{}.{}'.format( APP_NAME, 'controller')) # 将红图的每个api的tag注入SWAGGER_TAGS中 # @assigner.handle_rp # def handle_swagger_tag(api): # app.config['SWAGGER_TAGS'].append(api.tag) bp_list = assigner.create_bp_list() for url_prefix, bp in bp_list: app.register_blueprint(bp, url_prefix=url_prefix)
def auto_registration_flask_blueprint(blueprint_path, module_name): from __init__ import app for item in os.listdir(blueprint_path): if item in ignore_dir_list: continue current_level_path = os.path.join(blueprint_path, item) cur_module_name = module_name + '.' + item if os.path.isdir(current_level_path): auto_registration_flask_blueprint(current_level_path, cur_module_name) continue if not cur_module_name.endswith(flask_blueprint.file_tag): continue cur_module_name = cur_module_name[:(0 - len(flask_blueprint.file_tag))] target_dynamic_module = importlib.import_module(cur_module_name) if hasattr(target_dynamic_module, 'app'): app.register_blueprint(target_dynamic_module.app)
from flask import redirect, render_template, url_for, flash from __init__ import app # import route blueprints from routes.auth import auth from routes.main import main from routes.profile import profile from routes.post import post from routes.comment import comment # register app routes app.register_blueprint(auth) app.register_blueprint(main) app.register_blueprint(profile) app.register_blueprint(post) app.register_blueprint(comment) ############################################################ # ERROR ROUTES ############################################################ @app.errorhandler(404) def page_not_found(e): """display a 404 response page""" return render_template('404.html'), 404 @app.errorhandler(401) def not_authorized(e): """send the user to the login screen when they try to access a locked page"""
@socket.on('connect') def connect(): pass @socket.on('login') def login(): server_backgroud(robot.login) @socket.on('logout') def logout(): server_backgroud(robot.logout) host = '0.0.0.0' port = 9777 app.register_blueprint(api, url_prefix='/api') try: with open(CONF_PATH, 'rb') as conf: robot = pickle.load(conf) robot.load_config() except: robot = Group_robot() def end_process(name): if len(sys.argv) > 1: if sys.argv[1] == 'end': process_list = [p for p in psutil.process_iter() if p.name() == name] process_list.sort(key=lambda x: x.create_time()) for p in process_list: p.kill()
# -*- coding: utf-8 -*- from __init__ import app, WEB_IP, WEB_PORT from photo_tools_admin.controller import admin if __name__ == "__main__": app.register_blueprint(admin) if WEB_IP == 'localhost': # 本地调试 app.run(host='0.0.0.0', port=WEB_PORT, debug=False, threaded=True) # app.run() # ssl_context = ( # './server.crt', # './server_nopwd.key') else: from werkzeug.contrib.fixers import ProxyFix # 线上服务部署 对接gunicorn app.wsgi_app = ProxyFix(app.wsgi_app)
from flask import Flask, render_template, request, redirect, url_for import requests import sqlite3 as sl3 from models.lessons import LessonData from projectsearch.projectapp import projectsearch_bp from museum.user import app_crudu from __init__ import app #import storecom #import connection app.register_blueprint(projectsearch_bp) app.register_blueprint(app_crudu) ld = LessonData() # ld is an object that contains data for lesson @app.route('/') def index(): return render_template("homesite/index.html", menus=ld.menus) """Landing page from Menu selection""" @app.route('/landing/<selection>/', methods=['GET', 'POST']) def landing(selection): # POST redirection to content page if request.method == 'POST': form = request.form selection = form['page']
# @app.route('/') # def index(): # return render_template('index.html') # thread = None # def background_thread(): # while True: # socketio.emit('message', {'goodbye': "Goodbye"}) # time.sleep(5) # @socketio.on('connect') # def connect(): # global thread # if thread is None: # thread = socketio.start_background_task(target=background_thread) @app.errorhandler(CustomException) def own_error(error): response = jsonify({'msg': error.message}) response.status_code = 500 return response app.register_blueprint(user_api) app.register_blueprint(board_api) # socketio.run(app, debug=True) app.run(debug=True)
from flask import Flask from routes.main import main from __init__ import app app.register_blueprint(main, url_prefix='/api/main/get') @app.route('/') def main(): return 'Welcome to Flask demo' if(__name__) == '__main__': app.run()
from __init__ import app from routes import routes_blueprint app.register_blueprint(routes_blueprint) if __name__ == '__main__': app.run(host='192.168.1.105', port=5000, ssl_context=('cert.pem', 'key.pem'))
from __init__ import app, db, login_manager from flask_user import SQLAlchemyAdapter, UserManager from views import view from models import Users db_adapter = SQLAlchemyAdapter(db, Users) user_manager = UserManager(db_adapter, app, login_manager=login_manager) # Routing app.register_blueprint(view) if __name__ == "__main__": app.run(debug=True, host="localhost", port=5000)
return redirect(url_for("main_bp.returned")) #session data @main_bp.route('/get') @login_required def get_session(): return str(session.get("email")) + str(session.get("userID")) + str( session.get("userName")) + str(session.get("books")) #route to change your username @main_bp.route('/user', methods=['GET', 'POST']) @login_required def change_username(): form = SearchBook() form2 = changeUsernameForm() if form2.is_submitted(): current_user.username = form2.new_username.data db.session.commit() app.logger.info('Username Changed!') return redirect(url_for('main_bp.dashboard')) return render_template('change_username.html', form=form, form2=form2) app.register_blueprint(main) app.register_blueprint(main_bp) #runs the app if __name__ == "__main__": app.run(debug=True)
from DBConnection import DatabaseConnection from ErrorHandlers import error_handlers from __init__ import app from Profile import profile from Comment import comment from Follow import follow from Image import image from Auth import auth from Post import post from Star import star import settings api = Api(app) #Blueprint the other modules into the project app.register_blueprint(error_handlers) app.register_blueprint(auth) app.register_blueprint(profile) app.register_blueprint(post) app.register_blueprint(image) app.register_blueprint(comment) app.register_blueprint(follow) app.register_blueprint(star) # Redirect user from / to /post to avoid issues class Root(Resource): def get(self): return redirect(settings.APP_HOST + ":" + str(settings.APP_PORT) + "/post/recent", code=302)
from flask import Flask from __init__ import app from api.bairro_routes import bp_bairro from api.login_routes import bp_auth from api.alimento_routes import bp_alimentos app.register_blueprint(bp_bairro) app.register_blueprint(bp_auth) app.register_blueprint(bp_alimentos) if __name__ == '__main__': app.run()
from flask import redirect, render_template, url_for, flash, request from flask_login import login_url from __init__ import app # import route blueprints from routes.auth import auth from routes.main import main from routes.profile import profile from routes.cart import cart from routes.bakery import bakery from routes.image import image from routes.shopItem import shopItem # register app routes app.register_blueprint(auth) app.register_blueprint(main) app.register_blueprint(profile) app.register_blueprint(cart) app.register_blueprint(bakery) app.register_blueprint(image) app.register_blueprint(shopItem) ############################################################ # ERROR ROUTES ############################################################ @app.errorhandler(404) def page_not_found(e): """display a 404 response page""" return render_template('404.html'), 404
from Admin import admin from User import user from __init__ import app, db app.register_blueprint(admin, url_prefix='/api/admin') app.register_blueprint(user, url_prefix='/api/user') if __name__ == "__main__": # app.run(debug=True) # db.create_all() # Create tables app.run(host='0.0.0.0', port=80)
from flask import redirect, render_template, url_for, flash, request from flask_login import login_url from __init__ import app # import route blueprints from routes.auth import auth from routes.main import main from routes.profile import profile # register app routes app.register_blueprint(auth) app.register_blueprint(main) app.register_blueprint(profile) ############################################################ # ERROR ROUTES ############################################################ @app.errorhandler(404) def page_not_found(e): """display a 404 response page""" return render_template('404.html'), 404 @app.errorhandler(401) def not_authorized(e): """send the user to the login screen when they try to access a locked page""" flash("Confirm Your Identity to Proceed") return redirect(login_url("/login", next_url=url_for(request.endpoint)))
from data_model.channel import * from data_model.webhook import * from data_model.user import * from data_model.msg import * from data_model.re_url import * from api import * from api_sys import * from __init__ import app #app = Flask(__name__) app.config['SECRET_KEY'] = os.urandom(24) app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=31) app.register_blueprint(api) app.register_blueprint(api_sys) manager = Manager() # 登入管理者 @app.route("/login", methods=['GET', 'POST']) def login(): if request.method == "POST": manager_id = request.values["manager_id"] manager_pwd = request.values["manager_pwd"] # 先確認目前登入狀態 if (manager.chk_now() == True): return redirect(url_for("channel")) else: # 如果未登入就去驗證
from flask import render_template from __init__ import app from starter.starter import app_starter from algorithm.algorithm import app_algorithm from api.webapi import app_api from cruddy.app_crud import app_crud from cruddy.app_crud_api import app_crud_api from frontend.frontend import app_frontend from y2022 import app_y2022 app.register_blueprint(app_starter) app.register_blueprint(app_algorithm) app.register_blueprint(app_api) app.register_blueprint(app_crud) app.register_blueprint(app_crud_api) app.register_blueprint(app_frontend) app.register_blueprint(app_y2022) @app.route('/') def index(): return render_template("index.html") @app.errorhandler(404) def page_not_found(e): # note that we set the 404 status explicitly return render_template('404.html'), 404
from __init__ import app from api.role.role_routes import bp_role from api.users.users_routes import bp_users from api.predio.predio_routes import bp_predio from api.apartamento.apartamento_routes import bp_apartamento from api.access.access_routes import bp_acesso from api.dweller.dweller_routes import bp_morador from api.problem.problem_routes import bp_problema from api.employee.employee_routes import bp_employee from api.mail.mail_routes import bp_encomenda from api.event.event_routes import bp_evento from api.convidado.listaConvidado_routes import bp_convidado from api.sysaccess.sysaccess_routes import bp_auth app.register_blueprint(bp_role) app.register_blueprint(bp_users) app.register_blueprint(bp_predio) app.register_blueprint(bp_apartamento) app.register_blueprint(bp_acesso) app.register_blueprint(bp_morador) app.register_blueprint(bp_problema) app.register_blueprint(bp_employee) app.register_blueprint(bp_encomenda) app.register_blueprint(bp_evento) app.register_blueprint(bp_convidado) app.register_blueprint(bp_auth) if __name__ == '__main__': app.run()