當前位置: 首頁>>代碼示例>>Python>>正文


Python request.full_path方法代碼示例

本文整理匯總了Python中flask.request.full_path方法的典型用法代碼示例。如果您正苦於以下問題:Python request.full_path方法的具體用法?Python request.full_path怎麽用?Python request.full_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flask.request的用法示例。


在下文中一共展示了request.full_path方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: authed_only

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def authed_only(f):
    """
    Decorator that requires the user to be authenticated
    :param f:
    :return:
    """

    @functools.wraps(f)
    def authed_only_wrapper(*args, **kwargs):
        if authed():
            return f(*args, **kwargs)
        else:
            if (
                request.content_type == "application/json"
                or request.accept_mimetypes.best == "text/event-stream"
            ):
                abort(403)
            else:
                return redirect(url_for("auth.login", next=request.full_path))

    return authed_only_wrapper 
開發者ID:CTFd,項目名稱:CTFd,代碼行數:23,代碼來源:__init__.py

示例2: admins_only

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def admins_only(f):
    """
    Decorator that requires the user to be authenticated and an admin
    :param f:
    :return:
    """

    @functools.wraps(f)
    def admins_only_wrapper(*args, **kwargs):
        if is_admin():
            return f(*args, **kwargs)
        else:
            if request.content_type == "application/json":
                abort(403)
            else:
                return redirect(url_for("auth.login", next=request.full_path))

    return admins_only_wrapper 
開發者ID:CTFd,項目名稱:CTFd,代碼行數:20,代碼來源:__init__.py

示例3: check_account_visibility

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def check_account_visibility(f):
    @functools.wraps(f)
    def _check_account_visibility(*args, **kwargs):
        v = get_config(ConfigTypes.ACCOUNT_VISIBILITY)
        if v == AccountVisibilityTypes.PUBLIC:
            return f(*args, **kwargs)

        elif v == AccountVisibilityTypes.PRIVATE:
            if authed():
                return f(*args, **kwargs)
            else:
                if request.content_type == "application/json":
                    abort(403)
                else:
                    return redirect(url_for("auth.login", next=request.full_path))

        elif v == AccountVisibilityTypes.ADMINS:
            if is_admin():
                return f(*args, **kwargs)
            else:
                abort(404)

    return _check_account_visibility 
開發者ID:CTFd,項目名稱:CTFd,代碼行數:25,代碼來源:visibility.py

示例4: get_current_user

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def get_current_user():
    if authed():
        user = Users.query.filter_by(id=session["id"]).first()

        # Check if the session is still valid
        session_hash = session.get("hash")
        if session_hash:
            if session_hash != hmac(user.password):
                logout_user()
                if request.content_type == "application/json":
                    error = 401
                else:
                    error = redirect(url_for("auth.login", next=request.full_path))
                abort(error)

        return user
    else:
        return None 
開發者ID:CTFd,項目名稱:CTFd,代碼行數:20,代碼來源:__init__.py

示例5: before_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def before_request():
    ''' Pre-request hander '''
    logger.debug("Incoming Web Request: {0}".format(request.full_path))
    g.dbc = connect_db(app.config) 
開發者ID:madflojo,項目名稱:automatron,代碼行數:6,代碼來源:web.py

示例6: log_begin_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def log_begin_request():
    log.debug(u"Begin handling of request {!r}".format(request.full_path)) 
開發者ID:privacyidea,項目名稱:privacyidea,代碼行數:4,代碼來源:before_after.py

示例7: teardown_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def teardown_request(exc):
    call_finalizers()
    log.debug(u"End handling of request {!r}".format(request.full_path)) 
開發者ID:privacyidea,項目名稱:privacyidea,代碼行數:5,代碼來源:before_after.py

示例8: after_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def after_request(response):
	timestamp = strftime('[%Y-%b-%d %H:%M]')
	logger.error('%s %s %s %s %s %s',timestamp , request.remote_addr , \
				request.method , request.scheme , request.full_path , response.status)
	return response 
開發者ID:highoncarbs,項目名稱:shorty,代碼行數:7,代碼來源:app.py

示例9: exceptions

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def exceptions(e):
	tb = traceback.format_exc()
	timestamp = strftime('[%Y-%b-%d %H:%M]')
	logger.error('%s %s %s %s %s 5xx INTERNAL SERVER ERROR\n%s',
        timestamp, request.remote_addr, request.method,
        request.scheme, request.full_path, tb)
	return make_response(e , 405) 
開發者ID:highoncarbs,項目名稱:shorty,代碼行數:9,代碼來源:app.py

示例10: catch_all

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def catch_all(path):
	# Load the config file
	config=load_config()
	# Honeytoken alerts
	if request.path in config['traps'] and request.path != "/favicon.ico":
		# Preparing the alert message
		alertMessage = alert_msg(request, config)
		# Slack alert
		if config['alert']['slack']['enabled'] == "true":
			WEBHOOK_URL = config['alert']['slack']['webhook-url']
			slack_alerter(alertMessage, WEBHOOK_URL)
		# Email alert
		if config['alert']['email']['enabled'] == "true":
			email_alerter(alertMessage, config)
		# SMS alert
		#TODO: Complete and test the SMS alert
		#if config['alert']['sms']['enabled'] == "true":
		#	sms_alerter(alertMessage, config)
		#TODO: HTTP Endpoint Support
	# Honeypot event logs
	if request.headers.getlist("X-Forwarded-For"):
		source_ip = request.headers.getlist("X-Forwarded-For")[0]
	else:
		source_ip = request.remote_addr
	logger.info('{{"sourceip":"{}","host":"{}","request":"{}","http_method":"{}","body":"{}","user_agent":"{}"}}'.format(
		source_ip, request.url_root, request.full_path, request.method, request.data, request.user_agent.string))
	# Prepare and send the custom HTTP response
	contype, body = generate_http_response(request, config)
	# Customize the response using a template (in case you want to return a dynamic response, etc.)
	# You can comment the next 2 lines if you don't want to use this. /Just an example/
	if body == "custom.html":
		return (render_template(body, browser = request.user_agent.browser, ua = request.user_agent.string))
	return (send_file(body, mimetype=contype) if "image" in contype else render_template(body)) 
開發者ID:0x4D31,項目名稱:honeyku,代碼行數:35,代碼來源:honeyku.py

示例11: after_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def after_request(response):
    logger.info('%s %s %s %s %s', request.method,
                request.environ.get('HTTP_X_REAL_IP', request.remote_addr),
                request.scheme, request.full_path, response.status)
    return response 
開發者ID:521xueweihan,項目名稱:hellogithub.com,代碼行數:7,代碼來源:__init__.py

示例12: exceptions

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def exceptions(e):
    tb = traceback.format_exc()
    tb = tb.decode('utf-8')
    logger.error('%s %s %s %s 5xx INTERNAL SERVER ERROR\n%s',
                 request.environ.get('HTTP_X_REAL_IP', request.remote_addr),
                 request.method, request.scheme, request.full_path, tb)
    return '500 INTERNAL SERVER ERROR', 500 
開發者ID:521xueweihan,項目名稱:hellogithub.com,代碼行數:9,代碼來源:__init__.py

示例13: after_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def after_request(response):
    """After request handler."""
    service_log.info(
        '{0} {1} {2} {3} {4}'.format(
            request.remote_addr, request.method, request.scheme,
            request.full_path, response.status
        )
    )

    return response 
開發者ID:SwissDataScienceCenter,項目名稱:renku-python,代碼行數:12,代碼來源:entrypoint.py

示例14: exceptions

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def exceptions(e):
    """App exception logger."""
    tb = traceback.format_exc()
    service_log.error(
        '{} {} {} {} 5xx INTERNAL SERVER ERROR\n{}'.format(
            request.remote_addr, request.method, request.scheme,
            request.full_path, tb
        )
    )

    return e.status_code 
開發者ID:SwissDataScienceCenter,項目名稱:renku-python,代碼行數:13,代碼來源:entrypoint.py

示例15: after_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import full_path [as 別名]
def after_request(response):
    if response.status_code != 500:
        ts = strftime('[%Y-%b-%d %H:%M]')
        logger.info('%s %s %s %s %s %s',
                      ts,
                      request.remote_addr,
                      request.method,
                      request.scheme,
                      request.full_path,
                      response.status)
    return(response) 
開發者ID:kylechenoO,項目名稱:AIOPS_PLATFORM,代碼行數:13,代碼來源:WebApp.py


注:本文中的flask.request.full_path方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。