Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一个 Flask+SQLAlchemy 应用程序来替换很久以前开发的一系列 PHP 脚本。其中一个脚本取决于$_GET变量上可用的许多键,例如 appName。这些值是由我无法控制的外部应用程序发送的。
$_GET
从 Flask 捕获在 $_GET 上设置的键/值对的最佳方法是什么?
您真正需要做的就是检查request对象。要从请求中提取一个名为“foo”的变量,您将运行类似于以下内容:
request
request.args.get('foo', '');
这将返回foo参数的值,如果它不存在,它将返回一个默认的空字符串(get函数的第二个参数)。
foo
get
以下是相关文档: