【发布时间】:2020-09-17 13:53:40
【问题描述】:
我已部署到 App Engine 的一个简单的 flask+ react 网站在本地运行良好。 当我在本地提供 main.py 并转到 /hello 时,它应该返回“hello world”。但是,当部署到应用引擎并使用提供的 URL 和 /hello 时,它会返回“在此服务器上找不到请求的 URL /hello。”
下面是main.py
from flask import Flask, render_template
app = Flask(__name__, static_folder="./build/static", template_folder="./build")
@app.route("/")
def index():
return render_template("index.html")
@app.route("/hello")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run(host='127.0.0.1', port=8080, debug=True)
这是我的 app.yaml
runtime: python37
entrypoint: gunicorn -b :$PORT main:app
handlers:
- url: /
static_files: build/index.html
upload: build/index.html
- url: /
static_dir: build
- url: /(.*)
script: auto
project_root/
build/
static/
index.html
app.yaml
main.py
输入 [provided-url].com/ 时,它还会在应用引擎上正常返回 index.html
【问题讨论】:
标签: reactjs google-app-engine flask yaml app.yaml