align: классовый app.py, static/, Dockerfile как в шаблоне
This commit is contained in:
+19
-9
@@ -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():
|
||||
return render_template("index.html")
|
||||
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")
|
||||
|
||||
def health(self):
|
||||
return jsonify({"status": "ok"})
|
||||
|
||||
def run(self):
|
||||
self.app.run(debug=True, host="0.0.0.0", port=5000)
|
||||
|
||||
@app.route("/health")
|
||||
def health():
|
||||
return {"status": "ok"}
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
app_instance = ContractsApp()
|
||||
app_instance.run()
|
||||
|
||||
Reference in New Issue
Block a user