Restructure: site/ with modular code, matching Nubes Flask convention
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
"""Точка входа для gunicorn — app:app."""
|
|
||||||
from app import create_app
|
|
||||||
|
|
||||||
app = create_app()
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
"""Flask-приложение — фабрика."""
|
|
||||||
from flask import Flask
|
|
||||||
|
|
||||||
import config
|
|
||||||
|
|
||||||
|
|
||||||
def create_app() -> Flask:
|
|
||||||
app = Flask(__name__, static_folder="static", template_folder="templates")
|
|
||||||
app.config.from_object(config)
|
|
||||||
|
|
||||||
from app.routes.main import bp as main_bp
|
|
||||||
app.register_blueprint(main_bp)
|
|
||||||
|
|
||||||
return app
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
"""Конфигурация приложения — всё из переменных окружения."""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
# API облака
|
|
||||||
NUBES_API_ENDPOINT = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc")
|
|
||||||
NUBES_API_TOKEN = os.getenv("NUBES_API_TOKEN", "")
|
|
||||||
|
|
||||||
# Flask
|
|
||||||
SECRET_KEY = os.getenv("SECRET_KEY", "dev-secret-change-in-production")
|
|
||||||
DEBUG = os.getenv("DEBUG", "false").lower() == "true"
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
"""Точка входа."""
|
|
||||||
from app import create_app
|
|
||||||
|
|
||||||
app = create_app()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app.run(host="0.0.0.0", port=5000)
|
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
"""Точка входа — запускается как python site/app.py."""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# site/ не может быть пакетом (конфликт с stdlib site.py)
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
from routes.main import bp as main_bp
|
||||||
|
|
||||||
|
NUBES_API_ENDPOINT = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc")
|
||||||
|
NUBES_API_TOKEN = os.getenv("NUBES_API_TOKEN", "")
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config["NUBES_API_ENDPOINT"] = NUBES_API_ENDPOINT
|
||||||
|
app.config["NUBES_API_TOKEN"] = NUBES_API_TOKEN
|
||||||
|
app.register_blueprint(main_bp)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
"""GET /instances — получить список инстансов пользователя."""
|
"""GET /instances — получить список инстансов пользователя."""
|
||||||
|
|
||||||
from app.api.http_client import HttpClient
|
from api.http_client import HttpClient
|
||||||
|
|
||||||
|
|
||||||
def get_instances(client: HttpClient) -> list[dict]:
|
def get_instances(client: HttpClient) -> list[dict]:
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
from flask import Blueprint, current_app, render_template
|
from flask import Blueprint, current_app, render_template
|
||||||
|
|
||||||
from app.api.http_client import HttpClient
|
from api.http_client import HttpClient
|
||||||
from app.operations.get_instances import get_organization
|
from operations.get_instances import get_organization
|
||||||
|
|
||||||
bp = Blueprint("main", __name__)
|
bp = Blueprint("main", __name__)
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Reference in New Issue
Block a user