jab*_*son 8 python flask visual-studio-code
我正在寻求帮助,了解如何在 Visual Studio Code 中为集成终端设置环境变量。目前,我可以使用工作区文件夹中的.env文件来执行此操作,但我想更改此文件的文件名并创建另外一个或两个文件,例如 dev.env 和 prod.env。为我的工作区设置“ python.envFile ”并不能解决问题,据我了解,更改 launch.json 中的内容是为了调试。
所有这一切的总体目标(这很重要)是使用一组特定的环境变量运行 Flask shell(Flask Web 框架的集成 shell,Python),并能够通过交换文件来更改它们。我知道我可以通过在工作区设置中引入“ terminal.integrated.env.osx ”来设置这些变量,但我宁愿从文件中获取这些变量。
我想解决这个问题的一种方法是创建两个任务:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "FLASK SHELL DEV",
"type": "shell",
"command": "source ${workspaceFolder}/dev.env && ${config:python.pythonPath} -m flask shell",
"problemMatcher": []
},
{
"label": "FLASK SHELL PROD",
"type": "shell",
"command": "source ${workspaceFolder}/prod.env && ${config:python.pythonPath} -m flask shell",
"problemMatcher": []
}
]
}
Run Code Online (Sandbox Code Playgroud)
但问题依然存在。有没有办法用集成终端做同样的事情?
归档时间: |
|
查看次数: |
9304 次 |
最近记录: |