entire app update:
moder view app with static page, forgejo ci/cd workflow
This commit is contained in:
parent
25c896f809
commit
e6e700c2ee
13 changed files with 460 additions and 28 deletions
12
app/__init__.py
Normal file
12
app/__init__.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
from flask import Flask
|
||||
import os
|
||||
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
app.config.from_object('config.Config')
|
||||
|
||||
from app.routes import main
|
||||
app.register_blueprint(main)
|
||||
|
||||
return app
|
||||
27
app/routes.py
Normal file
27
app/routes.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from flask import Blueprint, render_template, jsonify
|
||||
import os
|
||||
import datetime
|
||||
|
||||
main = Blueprint('main', __name__)
|
||||
|
||||
@main.route('/')
|
||||
def index():
|
||||
return render_template('index.html',
|
||||
title='Flask CI/CD Demo',
|
||||
version=os.environ.get('APP_VERSION', '1.0.0'))
|
||||
|
||||
@main.route('/health')
|
||||
def health():
|
||||
return jsonify({
|
||||
'status': 'healthy',
|
||||
'timestamp': datetime.datetime.now().isoformat(),
|
||||
'environment': os.environ.get('FLASK_ENV', 'production')
|
||||
})
|
||||
|
||||
@main.route('/api/info')
|
||||
def info():
|
||||
return jsonify({
|
||||
'app': 'Flask CI/CD Demo',
|
||||
'version': os.environ.get('APP_VERSION', '1.0.0'),
|
||||
'commit': os.environ.get('COMMIT_HASH', 'unknown')
|
||||
})
|
||||
124
app/static/css/style.css
Normal file
124
app/static/css/style.css
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
nav {
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
padding: 1rem 2rem;
|
||||
}
|
||||
|
||||
.nav-container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nav-container h1 {
|
||||
color: #333;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.nav-links a {
|
||||
color: #555;
|
||||
text-decoration: none;
|
||||
margin-left: 2rem;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 4px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.nav-links a:hover {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
}
|
||||
|
||||
main {
|
||||
flex: 1;
|
||||
max-width: 1200px;
|
||||
margin: 2rem auto;
|
||||
padding: 0 2rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
padding: 2rem;
|
||||
box-shadow: 0 4px 20px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #333;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.status-card {
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
padding: 1.5rem;
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
|
||||
.status-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 0.5rem 0;
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.status-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.label {
|
||||
color: #666;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.value {
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.green {
|
||||
color: #28a745;
|
||||
}
|
||||
|
||||
.info-box {
|
||||
background: #e8f4fd;
|
||||
border-left: 4px solid #667eea;
|
||||
padding: 1.5rem;
|
||||
border-radius: 4px;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.info-box ol {
|
||||
margin-left: 1.5rem;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.info-box li {
|
||||
padding: 0.3rem 0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
footer {
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
text-align: center;
|
||||
padding: 1rem;
|
||||
color: #666;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
10
app/static/js/main.js
Normal file
10
app/static/js/main.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log('Flask CI/CD App загружен!');
|
||||
|
||||
// Добавляем время сборки если есть
|
||||
const footer = document.querySelector('footer p');
|
||||
if (footer) {
|
||||
const buildTime = new Date().toLocaleString('ru-RU');
|
||||
footer.textContent += ` | Собрано: ${buildTime}`;
|
||||
}
|
||||
});
|
||||
31
app/templates/base.html
Normal file
31
app/templates/base.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}{{ title }}{% endblock %}</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<div class="nav-container">
|
||||
<h1>🚀 Flask CI/CD</h1>
|
||||
<div class="nav-links">
|
||||
<a href="/">Главная</a>
|
||||
<a href="/health">Health</a>
|
||||
<a href="/api/info">API Info</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>Версия: {{ version }} | Сборка: {{ build_time if build_time else 'N/A' }}</p>
|
||||
</footer>
|
||||
|
||||
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
32
app/templates/index.html
Normal file
32
app/templates/index.html
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h2>Добро пожаловать в CI/CD пайплайн!</h2>
|
||||
<div class="status-card">
|
||||
<div class="status-item">
|
||||
<span class="label">Статус:</span>
|
||||
<span class="value green">✅ Работает</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="label">Версия:</span>
|
||||
<span class="value">{{ version }}</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span class="label">Окружение:</span>
|
||||
<span class="value">{{ env if env else 'production' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="info-box">
|
||||
<h3>Как это работает</h3>
|
||||
<ol>
|
||||
<li>Вы пушите код в master ветку</li>
|
||||
<li>Forgejo запускает CI пайплайн</li>
|
||||
<li>Собирается Docker образ</li>
|
||||
<li>Образ пушится в реестр</li>
|
||||
<li>Деплой на VPS сервер</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue