[英]How can I know if a user of my Flask WebApp use a Windows or Linux machine?
Is there something in the request object for example that tells me what system the user uses ?例如,请求对象中是否有某些内容告诉我用户使用的是什么系统?
If I have a path from a file sent by the user, I want to be able to know (without a regex) if it's a Windows or LINUX PATH.如果我有来自用户发送的文件的路径,我希望能够知道(没有正则表达式)它是 Windows 还是 LINUX PATH。
Is there an obvious way ?有明显的方法吗?
you can get User-Agent
header and parse it with werkzeug.useragents.UserAgent您可以获取
User-Agent
标头并使用werkzeug.useragents.UserAgent对其进行解析
from flask import request
from werkzeug.useragents import UserAgent
user_agent = UserAgent(request.headers.get('User-Agent'))
print(user_agent.platform)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.