Set-OPS-Public/promo/formation/dev-00/slides/python.html
Daniel Allaire 385e3f24e1 formation : le module D0 et le glossaire du developpeur (289)
Le parcours developpeur parlait la langue de Set-OPS des D1. D0, « De zero a en
ligne », fait le parcours entier sur deux depots minimaux, sans jargon, et situe
Set-OPS face a Heroku, Docker, Vercel et un VPS. Son application FastAPI a ete
lancee telle que montree, avec les paquets de Debian 13. Le glossaire traduit
47 mots du parcours, avec leur equivalent courant.

Publie par le site web de l'Alliance v1.5.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 19:06:38 -05:00

38 lines
4.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<section id="python" data-transition="fade" style="background:#131B36;color:#EEF2F8;font-family:'IBM Plex Sans', Arial, sans-serif;padding:128px 128px 160px;display:flex;flex-direction:column;gap:36px">
<div style="display:flex;flex-direction:column;gap:16px">
<p style="font-size:24px;letter-spacing:3px;text-transform:uppercase;color:#4FE3C1;font-weight:600">Étape 1 · écrire</p>
<h2 style="font-family:'Source Serif 4', Georgia, serif;font-size:68px;font-weight:400;line-height:1.1;color:#EEF2F8">Une application Python : quatre fichiers aussi.</h2>
</div>
<div style="display:flex;gap:32px;align-items:stretch">
<div style="display:flex;flex-direction:column;gap:4px;background:#0B1022;padding:30px 32px;border-radius:20px;border-top:6px solid #56C2FF;font-family:'JetBrains Mono', 'Courier New', monospace;font-size:24px;line-height:1.45">
<p style="font-family:'IBM Plex Sans', Arial, sans-serif;font-size:24px;letter-spacing:2px;text-transform:uppercase;color:#56C2FF;font-weight:600">Le dépôt</p>
<p style="font-size:24px;color:#EEF2F8;white-space:pre">mon-app/</p>
<p style="font-size:24px;color:#EEF2F8;white-space:pre">├── setops-app.yml</p>
<p style="font-size:24px;color:#EEF2F8;white-space:pre">├── app/</p>
<p style="font-size:24px;color:#EEF2F8;white-space:pre">│ ├── __init__.py</p>
<p style="font-size:24px;color:#EEF2F8;white-space:pre">│ └── main.py</p>
<p style="font-size:24px;color:#EEF2F8;white-space:pre">└── donnees/</p>
</div>
<div style="flex:1;display:flex;flex-direction:column;gap:4px;background:#0B1022;padding:30px 32px;border-radius:20px;border-top:6px solid #4FE3C1;font-family:'JetBrains Mono', 'Courier New', monospace;font-size:19px;line-height:1.45">
<p style="font-family:'IBM Plex Sans', Arial, sans-serif;font-size:24px;letter-spacing:2px;text-transform:uppercase;color:#4FE3C1;font-weight:600">app/main.py</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre">import os</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre">from pathlib import Path</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre">from fastapi import FastAPI</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre">ETAT = Path(__file__).parent.parent / &quot;donnees&quot;</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre">CLE = os.environ[&quot;CLE_API&quot;] # le secret</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre">app = FastAPI()</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre">@app.get(&quot;/sante&quot;)</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre">def sante():</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre"> return {&quot;ok&quot;: True}</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre">@app.get(&quot;/&quot;)</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre">def accueil():</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre"> visites = ETAT / &quot;visites.txt&quot;</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre"> n = int(visites.read_text()) + 1 if visites.exists() else 1</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre"> visites.write_text(str(n))</p>
<p style="font-size:19px;color:#EEF2F8;white-space:pre"> return {&quot;visites&quot;: n}</p>
</div>
</div>
<p style="position:absolute;left:128px;bottom:64px;width:1400px;font-size:24px;color:#8592AD">Set-OPS · Formation · Module D0 — De zéro à en ligne</p>
<p style="position:absolute;right:128px;bottom:64px;width:120px;text-align:right;font-size:24px;color:#8592AD">08</p>
<aside>Le même parcours, pour une application Python. Quatre fichiers encore. Le code tient en une vingtaine de lignes de FastAPI. Il lit un secret, CLE_API, dans son environnement : c’est ainsi que tous les secrets arrivent. Il expose un chemin de santé, /sante, qui répond toujours vite. Et sa page d’accueil compte les visites dans un fichier, sous donnees : c’est le seul dossier où l’application a le droit d’écrire, et c’est lui qui est sauvegardé chaque nuit. Écrire ailleurs, à côté du code par exemple, serait perdu à la version suivante. Remarquez ce qui manque : aucune adresse, aucun mot de passe, aucun nom de machine.</aside>
</section>