fix: структура как у BG — class-based, debug=True, Dockerfile, чистый requirements
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY site site
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["python", "site/app.py"]
|
||||
@@ -1,4 +1,2 @@
|
||||
Flask==2.0.1
|
||||
Werkzeug==2.3.7
|
||||
requests>=2.31
|
||||
gunicorn>=21.2
|
||||
|
||||
+16
-9
@@ -1,18 +1,25 @@
|
||||
from flask import Flask, jsonify, render_template
|
||||
|
||||
app = Flask(__name__)
|
||||
from flask import Flask, render_template, jsonify
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
class SayApp:
|
||||
def __init__(self):
|
||||
self.app = Flask(__name__, template_folder="templates", static_folder="static")
|
||||
self.add_routes()
|
||||
|
||||
def add_routes(self):
|
||||
self.app.add_url_rule("/", "index", self.index)
|
||||
self.app.add_url_rule("/health", "health", self.health)
|
||||
|
||||
def index(self):
|
||||
return render_template("index.html")
|
||||
|
||||
|
||||
@app.route("/health")
|
||||
def health():
|
||||
def health(self):
|
||||
return jsonify({"status": "ok"})
|
||||
|
||||
def run(self):
|
||||
self.app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000)
|
||||
SayApp().run()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user