Files
varlog/d146010e-a83b-44bb-885b-72845ae54e0c/index.md
T
2026-05-15 10:37:48 +02:00

20 lines
974 B
Markdown
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.
# Fournir un service http en Python
![](do_web_python.png)
Le bout de code suivant permet dexécuter temporairement un service http (80/tcp) en **Python**.
Le dossier où vous vous trouvez devient le "BaseHTTP", c'est-à-dire la racine du site accessible en http. Dans l'exemple, il s'agit du dossier `/tmp/certbot/public_html`.
Si vous avez déjà un service httpd comme Apache qui fonctionne et occupe déjà le port 80, il faudra veiller à l'arrêter avant.
```python
mkdir -p /tmp/certbot/public_html/.well-known/acme-challenge
cd /tmp/certbot/public_html
printf "%s" asFY_-_9W8N-Z4zPKwXvu5_pBv1kMAC4j3ag7VWFAko.Rj9bJx4j8slMw-Pxkq47MKU3TybtCD4ohJxc6kafaX0 > .well-known/acme-challenge/asFY_-_9W8N-Z4zPKwXvu5_pBv1kMAC4j3ag7VWFAko
sudo $(command -v python2 || command -v python2.7 || command -v python2.6) -c "import BaseHTTPServer, SimpleHTTPServer; \
s = BaseHTTPServer.HTTPServer(('', 80), SimpleHTTPServer.SimpleHTTPRequestHandler); \
s.serve_forever()"
```