python flask detect browser language
2016-06-08 13:28
621 查看
python flask detect browser language
No problem. We won't show you that ad again. Why didn't you like it?
Uninteresting
Misleading
Offensive
Repetitive
Other
Oops! I didn't mean to do this.
up vote-2down votefavorite | I need to get the browser language with Python flask. I have tried to use:request.headers.get('languages') This however returns None. I tried whoer.net and it returned it-ITfor my browser language. How can I detect the browser language with Python flask ? python flask
| ||||
|
2 Answers 2
active oldest votesup vote0down vote | You should check HTTP_ACCEPT_LANGUAGE
| ||||
|
Uninteresting
Misleading
Offensive
Repetitive
Other
Oops! I didn't mean to do this.
up vote0down vote | Check out Werkzeug's LanguageAccept data structure, or just try something like this to get a best match:supported_languages = ["en", "nl", "it"] lang = request.accept_languages.best_match(supported_languages) If you need more than that, then check out Flask-Babel. |
相关文章推荐
- Python内置函数
- python基础随笔
- python案例-用户登录
- python_Day_02[数组、列表、元组之篇]
- python使用zmq通信
- python面向对象
- Python学习笔记-第一个小游戏Pyglatin
- Scrapy 1.2 + Python 3.5 在 Windows 上的安装方法
- python __doc__ 文档说明
- Python中sorted()方法
- 浅谈Python数据类型之间的转换
- Python爬虫实战(2):爬取京东商品列表
- Python正则表达式如何进行字符串替换
- 浅谈python 四种数值类型(int,long,float,complex)
- Python入门:os部分方法介绍(二)
- Python while 循环使用的简单实例
- Python爬虫实战(2):爬取京东商品列表
- Pycharm2016.2注册码(python编码利器)
- Pandas DataFrame 日常的操作与发现
- Windows下 Python3.5 运行环境的搭建