我正在使用 Flask 构建一个 Web 表单,希望用户能够输入多个条目,并在将数据发送到数据库之前让他们有机会使用撤消按钮后悔输入。我正在尝试使用Flask-Caching但未能正确设置它。
我已经按照Flask Mega-Tutorial来设置 Flask(这是我的第一个 Flask 应用程序)。
+---app
| | forms.py
| | routes.py
| | __init__.py
| +---static
| +---templates
Run Code Online (Sandbox Code Playgroud)
我想知道我需要如何配置 Flask 应用程序才能基本上能够执行以下操作:
cache.add("variable_name", variable_data)
variable_name = cache.get("variable_name")
cache.clear()
Run Code Online (Sandbox Code Playgroud)
在其中一页(带有 @app.route 装饰器的函数)?
在应用程序中。init.py我有:
from flask import Flask
from config import Config
from flask_caching import Cache
app = Flask(__name__)
app.config.from_object(Config)
cache = Cache(app, config={'CACHE_TYPE': 'simple'})
from app import routes
Run Code Online (Sandbox Code Playgroud)
在routes.py中我有:
from flask import current_app
Run Code Online (Sandbox Code Playgroud)
当我尝试调用缓存时,我使用下面的代码。
current_app.cache.add("variable_name", variable_data)
Run Code Online (Sandbox Code Playgroud)
当我尝试使用该表单时,出现以下错误:
AttributeError: 'Flask' object …Run Code Online (Sandbox Code Playgroud) 我怎么知道 GitHub 服务器 rsa2 密钥指纹ssh-rsa 2048 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48与他们在其网站上显示的指纹相匹配,SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 (RSA)因为它们看起来不一样?
我正在设置我的 GitHub 帐户以使用 SSH 提交代码。在第一次访问尝试和腻子想要缓存密钥时出现问题。从网络上足够多的来源中,我发现足以确信它实际上是 GitHub,但我如何亲自验证它?意识到欺骗风险等,但这不是问题。
第一次ssh-rsa 2048尝试后,我从腻子中获得了指纹git clone [repository ssh url]。
我有一个带有子模块的存储库,当我推送到某些分支或标签时,我正在创建一个构建。我遇到的问题是我的结帐步骤无法访问我的子模块。设置是:
我试过使用 GitHub Actionactions/checkout@v2无济于事。如下所示,我尝试使用“ssh-key”选项,其中我已将公钥添加到子模块存储库部署密钥,并将私钥添加到我运行操作的存储库的机密中。我收到以下错误消息:
Fetching the repository
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin __myrepo__
ERROR: Repository not found.
Error: fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
The process '/usr/bin/git' failed with exit code 128
Waiting 13 seconds before trying again
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin __myrepo__
ERROR: Repository …Run Code Online (Sandbox Code Playgroud)