« Outils » : différence entre les versions
De EC_Wiki
Autres actions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 20 : | Ligne 20 : | ||
Puis mettre : | Puis mettre : | ||
from flask import Flask, render_template | |||
app = Flask(__name__) | |||
SERVICES = [ | |||
{ | |||
"name": "Nextcloud", | |||
"url": "https://cloud.ec-informatique.fr", | |||
"description": "Cloud personnel" | |||
}, | |||
{ | |||
"name": "MeshCentral", | |||
"url": "https://support.ec-informatique.fr", | |||
"description": "Support distant" | |||
}, | |||
{ | |||
"name": "Grafana", | |||
"url": "https://grafana.ec-informatique.fr", | |||
"description": "Monitoring" | |||
}, | |||
{ | |||
"name": "Wiki", | |||
"url": "https://wiki.ec-informatique.fr", | |||
"description": "Documentation infrastructure" | |||
}, | |||
] | |||
@app.route('/') | |||
def index(): | |||
return render_template('index.html', services=SERVICES) | |||
if __name__ == '__main__': | |||
app.run(host='0.0.0.0', port=5050) | |||
== Étape 5 — Créer le template HTML == | == Étape 5 — Créer le template HTML == | ||
| Ligne 94 : | Ligne 95 : | ||
<body> | <body> | ||
<h1>Infrastructure EC-Informatique</h1> | |||
<div class="grid"> | |||
{% for service in services %} | {% for service in services %} | ||
<div class="card"> | <div class="card"> | ||
<h2>{{ service.name }}</h2> | <h2>{{ service.name }}</h2> | ||
<p>{{ service.description }}</p> | |||
<a href="{{ service.url }}"> | <a href="{{ service.url }}"> | ||
Accéder | |||
</a> | |||
</div> | </div> | ||
{% endfor %} | {% endfor %} | ||
Dernière version du 14 mai 2026 à 14:27
Retour Linux | Accueil | Architecture Infra Finale
Étape 1 — Préparer le dossier de l’application modifier
Création l’arborescence :
sudo mkdir -p /opt/outils/templates sudo mkdir -p /opt/outils/static
Étape 2 — Créer l’environnement Python modifier
cd /opt/outils sudo python3 -m venv venv
Étape 3 — Installer Flask + Gunicorn modifier
sudo /opt/outils/venv/bin/pip install flask gunicorn
Étape 4 — Créer l’application Flask modifier
Créer :
sudo nano /opt/outils/app.py
Puis mettre :
from flask import Flask, render_template
app = Flask(__name__)
SERVICES = [
{
"name": "Nextcloud",
"url": "https://cloud.ec-informatique.fr",
"description": "Cloud personnel"
},
{
"name": "MeshCentral",
"url": "https://support.ec-informatique.fr",
"description": "Support distant"
},
{
"name": "Grafana",
"url": "https://grafana.ec-informatique.fr",
"description": "Monitoring"
},
{
"name": "Wiki",
"url": "https://wiki.ec-informatique.fr",
"description": "Documentation infrastructure"
},
]
@app.route('/')
def index():
return render_template('index.html', services=SERVICES)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5050)
Étape 5 — Créer le template HTML modifier
Créer :
sudo nano /opt/outils/templates/index.html
Puis :
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Infrastructure EC-Informatique</title>
<style>
body {
font-family: Arial, sans-serif;
background: #111827;
color: white;
margin: 40px;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
}
.card {
background: #1f2937;
padding: 20px;
border-radius: 10px;
}
a {
color: #60a5fa;
text-decoration: none;
}
</style>
</head>
<body>
Infrastructure EC-Informatique
{% for service in services %}
{% endfor %}
</body> </html>
Étape 6 — Tester localement modifier
Lancer :
cd /opt/outils sudo /opt/outils/venv/bin/python app.py
On doit voir :
Running on http://0.0.0.0:5050
Configuration Service modifier
En-tête modifier
Nom du service : URL : Fonction : Type : Exposition :
Infrastructure modifier
Machine hôte : Docker / VM / service : Port interne : Dépendances : Volumes : Base de données :
Reverse proxy modifier
Vhost nginx : Certificat SSL : Proxy_pass :
Sauvegarde modifier
Méthode : Fréquence : Emplacement :
Sécurité modifier
Auth MFA : VPN requis: Fail2ban : Firewall :