获取$_SERVER['HTTP_USER_AGENT'] 瓶中的变量值[英] Get $_SERVER['HTTP_USER_AGENT'] variable value in Bottle

本文是小编为大家收集整理的关于获取$_SERVER['HTTP_USER_AGENT'] 瓶中的变量值的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我是Python瓶框架的新手,需要专门获得$ _server ['http_user_agent']变量值.请有人解释我该如何实现这一目标.

推荐答案

尝试:

import request, route, run

@route('/user-agent')
def user_agent():
    return request.environ.get('HTTP_USER_AGENT')
run()

本文地址:https://www.itbaoku.cn/post/1975369.html

问题描述

I am new to python bottle framework and need to get $_SERVER['HTTP_USER_AGENT'] variable value specially. Pleas can some one explain how can I achieve this.

推荐答案

Try it:

import request, route, run

@route('/user-agent')
def user_agent():
    return request.environ.get('HTTP_USER_AGENT')
run()