python学习
This commit is contained in:
@@ -5,6 +5,7 @@ from flask import request,g,redirect
|
||||
from common.models.User import ( User )
|
||||
from common.libs.user.UserService import ( UserService )
|
||||
from common.libs.UrlManager import ( UrlManager )
|
||||
from common.libs.LogService import LogService
|
||||
|
||||
import re
|
||||
@app.before_request
|
||||
@@ -22,7 +23,8 @@ def before_request():
|
||||
g.current_user=None
|
||||
if user_info:
|
||||
g.current_user=user_info
|
||||
|
||||
# 加入日志
|
||||
LogService.addAccessLog()
|
||||
pattern = re.compile('%s' % "|".join(ignore_urls))
|
||||
if pattern.match(path):
|
||||
return
|
||||
|
||||
9
web/interceptors/ErrorInterceptor.py
Normal file
9
web/interceptors/ErrorInterceptor.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from application import app
|
||||
from common.libs.Helper import ops_render
|
||||
from common.libs.LogService import LogService
|
||||
|
||||
@app.errorhandler( 404 )
|
||||
def error_404( e ):
|
||||
LogService.addErrorLog( str( e ) )
|
||||
return ops_render( 'error/error.html',{ 'status':404,'msg':'很抱歉!您访问的页面不存在' } )
|
||||
Reference in New Issue
Block a user