#模块管理
from flask import Blueprint

route_icc = Blueprint('icc',__name__)


@route_icc.route('/')
def index():
    return 'icc index'


@route_icc.route('/hello')
def hello():
    return 'icc hello'

app = Flask(__name__)
app.register_blueprint(route_icc,url_prefix='/icc')
#链接及版本管理

class UrlManager():

    @staticmethod
    def buildUrl(path):
        return path

    @staticmethod
    def buildStaticUrl(path):
        #版本号
        path = path+'?ver='+'202004162200'
        return UrlManager.buildUrl(path)


from common.libs.UrlManager import UrlManager

@app.route('/')
def hello_world():
    url = url_for('index')
    url_1 = UrlManager.buildUrl('/api')
    url_2 = UrlManager.buildStaticUrl('/css/bootstrap.css')
    return 'Hello World!' + url + url_1 + url_2
#日志管理
    msg = 'Hello World!' + url + url_1 + url_2
    app.logger.info(msg)
    app.logger.error(msg)
    app.logger.debug(msg)

#错误管理
@app.errorhandler(404)
def page_not_found(error):
    app.logger.error(error)
    return 'this page does not exist',404

 

相关文章:

  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-24
  • 2021-11-07
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案