align: классовый app.py, static/, Dockerfile как в шаблоне
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY site /app/site
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["python", "site/app.py"]
|
||||
+18
-8
@@ -1,14 +1,24 @@
|
||||
from flask import Flask, render_template
|
||||
from flask import Flask, render_template, jsonify
|
||||
|
||||
app = Flask(__name__)
|
||||
class ContractsApp:
|
||||
def __init__(self):
|
||||
self.app = Flask(__name__)
|
||||
self.add_routes()
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
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():
|
||||
return {"status": "ok"}
|
||||
def health(self):
|
||||
return jsonify({"status": "ok"})
|
||||
|
||||
def run(self):
|
||||
self.app.run(debug=True, host="0.0.0.0", port=5000)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
app_instance = ContractsApp()
|
||||
app_instance.run()
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
max-width: 600px;
|
||||
margin: 100px auto;
|
||||
text-align: center;
|
||||
color: #333;
|
||||
}
|
||||
h1 { color: #2c3e50; }
|
||||
@@ -2,11 +2,9 @@
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Contracts App</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; max-width: 600px; margin: 100px auto; text-align: center; }
|
||||
h1 { color: #333; }
|
||||
</style>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Contracts App 🚀</h1>
|
||||
|
||||
Reference in New Issue
Block a user