![](/img/trans.png)
[英]Localhost has stopped updating when various flask/python scripts are run, how do I fix this?
[英]How do I run a Flask API that has Pulumi code?
我是 Pulumi 的新手和新手。 我想寫一個 Flask API 使用 Pulumi 提供 Scaleway 實例。 我這樣做可能完全錯了,但我認為它將作為觸發 Pulumi 代碼的常規 api 端點工作。
主要.py:
import pulumi
import pulumi_scaleway as scaleway
import flask
app = flask.Flask(__name__)
app.config["DEBUG"] = True
@app.route('/', methods=['GET'])
def home():
return "<h1>Hello</p>"
@app.route('/create', methods=['GET'])
def create():
public_ip = scaleway.InstanceIp("example")
server = scaleway.InstanceServer("example",
image="ubuntu_focal",
type="DEV1-S",
ip_id=public_ip.id,
tags=["python"]
)
if __name__ == '__main__':
app.run()
當我做pulumi up
我得到:
/home/.../venv/bin/python: No module named
error: an unhandled error occurred: Program exited with non-zero exit code: 1
我真的不明白這里的錯誤是什么意思,有人知道我應該如何處理 go 嗎?
edit1:感謝 [pulumi/automation-api-examples][1] 回購,弄清楚我做錯了什么。 我將__ main__.py重命名為app.py並做了FLASK_RUN_PORT=1337 FLASK_ENV=development venv/bin/flask run
edit2:在我將 API 部署到容器中后,上述解決方案不起作用。 現在我Program run without the Pulumi engine available; re-run using the
使用 pulumi CLI
錯誤Program run without the Pulumi engine available; re-run using the
多虧了pulumi/automation-api-examples 存儲庫,我才知道我做錯了什么。 我將__ main__.py重命名為app.py並做了FLASK_RUN_PORT=1337 FLASK_ENV=development venv/bin/flask run
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.