我决定使用 github action 来显示我的网页并使用 Python Flask 对其进行格式化,但我无法让它工作...一切正常,没有错误,并且 Flask 一直在生产端口(0.0 .0.0),但它似乎没有监听任何内容,我转到我制作的 github 页面的 url,什么也没有,就好像它没有监听任何内容或发送请求一样。
这是我的 YML 代码:
name: page
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on:
push:
branches:
- main
permissions:
contents: "write"
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: production
steps:
- name: Installing dependencies
run: python -m pip install Flask
- run: echo "Iniciando..."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "Creando servidor..."
- name: Init server
run: python "${{ github.workspace }}/server.py"
这是我的Python代码:
from flask import Flask, request, Blueprint, render_template;
app = Flask(__name__);
DEBUG=False;
#Registramos una nueva url
media_pt=Blueprint("media", __name__, static_folder="./media", static_url_path="/media");
app.register_blueprint(media_pt);
media_pt=Blueprint("static", __name__, static_folder="./static", static_url_path="/static");
app.register_blueprint(media_pt);
@app.route("/")
def index():
return render_template("index.html");
@app.route("/ok")
def is_of():
return "is okk";
if __name__=="__main__":
app.run(host="0.0.0.0",debug=DEBUG)
首先,不管github页面给了我一个404错误,现在我配置了项目的根目录,它只返回自述文件(因为没有获取index.html(我将其放在模板文件夹中) )
从评论中复制。
因此,这两者绝不支持您尝试托管 Flask Web 应用程序。
要解决此问题,您通常必须为正确的托管平台付费。