document.write(`
<div style="padding: 30px;">
<h2>Uploader un fichier</h2>
<!-- Input file -->
<input type="file" id="fileInput" accept="*/*">
<button id="uploadBtn">Upload</button>
<!-- Zone d'affichage -->
<p id="fileStatus" style="color: blue; font-weight: bold;"></p>
<!-- Zone console Python -->
<div id="ab-python-console" style="padding-top:20px;"></div>
</div>
<script>
const fileInput = document.getElementById("fileInput");
const uploadBtn = document.getElementById("uploadBtn");
const fileStatus = document.getElementById("fileStatus");
uploadBtn.addEventListener("click", () => {
const file = fileInput.files[0];
if (!file) {
fileStatus.textContent = "⚠️ Aucun fichier sélectionné.";
fileStatus.style.color = "red";
return;
}
fileStatus.style.color = "green";
fileStatus.textContent = \`✅ Fichier "\${file.name}" chargé avec succès (\${(file.size / 1024).toFixed(2)} Ko).\`;
const reader = new FileReader();
reader.onload = (event) => {
console.log("Contenu du fichier :", event.target.result);
};
reader.readAsText(file);
});
</script>
<script type="mpy">
print ("<h1> Python on Ancient Brain </h1>")
print ("<p style='color:green'><b> Python demo generating prime numbers and printing them </b></p>")
# --- generate prime numbers: -----------------------------------------------------
primes = [2]
num = 3
while len(primes) < 100:
if all(num % p != 0 for p in primes):
primes.append(num)
print(num)
num += 2
</script>
`);