ガイド一覧

Python · Flask

Runs app.py, or use gunicorn.

  1. 1app.py

    The platform sets the PORT environment variable (default 8080). Listen on 0.0.0.0:$PORT.

    python
    import os
    from flask import Flask
    app = Flask(__name__)
    
    @app.get("/")
    def hello():
        return "Hello OneCloud"
    
    if __name__ == "__main__":
        app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))
  2. 2Production start command (recommended)

    bash
    gunicorn app:app --bind 0.0.0.0:$PORT
  3. 3Deploy (pick one)

    ① Connect GitHub: Project → Add service → GitHub repository (deploys on push) ② From this folder: oc up --wait (builds even without a Dockerfile) ③ Upload a folder or zip in the console: Add service → Upload source

    bash
    oc login
    oc project create my-app --link
    oc up --wait

関連ガイド