Table des matières
- 2026:
- 2025:
4 billet(s) pour septembre 2026
| Notes HTTP Strict Transport Security - HSTS | 2026/09/18 11:04 | Jean-Baptiste |
| Notes GNU Linux GPU carte graphiques | 2026/09/08 15:49 | Jean-Baptiste |
| Notes GNU Linux graphique | 2026/09/08 15:42 | Jean-Baptiste |
| Notes urlencoding - passer des mots de passe en HTTPS | 2026/09/03 17:58 | Jean-Baptiste |
Python IDE
Voir aussi :
- PyDev (Eclipse)
- Jupyter (iPython)
- Atom
IDE dans le cloud (Code Ready Workspaces, Code Spaces, Gitpod…)
PyCharm
Install de PyCharm
apt install python-pip python3-pip snapd snap install pycharm-community --classic
Modules
Debug
apt-get install python3-dev
et Shift + F9
Visual Studio code - VSCodium - vscode
Voir aussi
- Red Hat OpenShift Dev Spaces (similaire à Gitpod)
snap install codium --classic
Atom
Geany
Dark mode
mkdir ~/.config/geany/colorschemes/ cd ~/.config/geany/colorschemes/ wget https://raw.githubusercontent.com/geany/geany-themes/master/colorschemes/darcula.conf
Choose the theme on Geany by going to the view menu and selecting Change Color Scheme…
Source : https://draculatheme.com/geany
Python GUI mobile smartphone
Voir :
- Kivy
- BeeWare / Toga
Kivy
Voir :
- kvlang / Kv language
sudo apt update sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev #pip3 install --user --upgrade Cython==0.29.19 virtualenv # the --user should be removed if you do this in a venv sudo apt-get install cython3 pipenv install kivy buildozer pipenv shell buildozer init pip3 install Cython buildozer -v android debug
Python Flask Gunicorn - Alternative à CGI
Voir :
Alternative à Flask :
- CherryPy
- Falcon
Alternative à Unicorn
- Uvicorn
apt-get install python3-flask gunicorn3
wsgi.py
#! /usr/bin/env python3 from plopweb import app if __name__ == "__main__": app.run( host="0.0.0.0", port=int("5001") )
plopweb.py
#! /usr/bin/env python3 import subprocess from flask import Flask, request, send_from_directory, after_this_request, abort app = Flask(__name__) from subprocess import call LOGFILE='/tmp/plop.txt' CMD_ANSIBLE='/usr/bin/ansible-playbook' def bash_command(cmd): subprocess.Popen(cmd, shell=True, executable='/bin/bash') @app.route('/') def hello_world(): return 'Hello World!' @app.route('/hello', methods=['POST']) def hello(): playbook = request.form['playbook'] ip = request.environ['REMOTE_ADDR'] bash_command('echo ' + CMD_ANSIBLE + ' ' + playbook +' -i ' + ip + ',' + '>>' + LOGFILE + ' 2>&1') return ` if __name__ == '__main__': app.run( debug=True, host="0.0.0.0", port=int("5001") )
wsgi.py
#! /usr/bin/env python3 from plopweb import app if __name__ == "__main__": app.run( host="0.0.0.0", port=int("5001") )
gunicorn3 --bind 0.0.0.0:5001 wsgi:app
Avec ça vous pouvez faire un script SystemD ou utiliser Supervisor, et mettre un nginx en reverse proxy
Exemple supervisor
apt-get install supervisor
supervisor-plopweb.conf
[program:plopweb] command = gunicorn3 --bind 127.0.0.1:8000 wsgi:app directory = /home/pkiweb/bin user = plopweb
Exemple de conf nginx
plopweb
server { listen 443 ssl; server_name plopweb.lan ; access_log /var/log/nginx/plopweb-ssl-access.log; error_log /var/log/nginx/plopweb-ssl-error.log; ssl_certificate /etc/nginx/ssl/plopweb.lan.combined.crt; ssl_certificate_key /etc/nginx/ssl/plopweb.lan.key; ssl_client_certificate /etc/nginx/ssl/ca.crt; ssl_verify_client on; location / { proxy_pass http://localhost:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }
Python, Flask et Supervisor à la place des vieilles CGI
Quand nous faisons une requête web (un POST par exemple) sur une URL, nous souhaitons lancer la commande ci-dessous
./script.sh -a -f prefix-/${POST_VAR} >> plop.log 2>&1
Voici une alternative aux CGI
Si besoin activer les dépôts backports :
echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list apt-get update
apt-get install python3-flask gunicorn3 supervisor
plop.py
#! /usr/bin/env python3 import subprocess import re from flask import Flask, request, send_from_directory, after_this_request, abort app = Flask(__name__) from subprocess import call LOGFILE='plop.log' # MUST BE ENDED BY "/" DL_DIR='/home/plop/foo/' SCRIPT_ARGS='-a -f' SCRIPT='./script.sh' def bash_command(cmd): subprocess.Popen(cmd, shell=True, executable='/bin/bash') @app.route('/') def hello_world(): return 'Hello World!' @app.route('/hello/', methods=['POST']) def hello(): var_post = request.form['var_post'] bash_command(SCRIPT + ' ' + SCRIPT_ARGS + ' ' + 'prefix-' + var_post + ' >>' + LOGFILE + ' 2>&1') return ` @app.route('/dl/<codename>') def download_file(filename): @after_this_request def delete_file(response): if re.match('^prefix-.*\.key$', filename): bash_command('shred -u ' + DL_DIR + filename) return response if re.match('^prefix-', filename): return send_from_directory(DL_DIR, filename, as_attachment=True) else: abort(403) if __name__ == '__main__': app.run( #debug=True, #host="0.0.0.0", port=int("5001") )
Pour tester sur le post TCP 5001 avant du passer en prod sur le port 8000
wsgi.py
#! /usr/bin/env python3 from plop import app if __name__ == "__main__": app.run()
/etc/supervisor/conf.d/plop.conf
[program:plop] command = gunicorn3 --bind 127.0.0.1:8000 wsgi:app directory = /home/plop/bin user = plop
Note : A la place du Supervisor elle est possible d'utiliser SystemD ou S6
Python Documentation
Voir :
- sphinx et sphinx-lint
- doxygen
