[Gandi] [Simple Hosting] Installation d’une application avec Flask.
Distribution de travail : Ubuntu
1/ Répertoire de travail :
[~] ➔ mkdir -p PYTHON/FLASK [~] ➔ cd PYTHON/FLASK/ [~/PYTHON/FLASK] ➔
2/ Télécharger le code source :
[~/PYTHON/FLASK] ➔ git clone http://github.com/pallets/flask.git
3/ Installation de Flask :
[~/PYTHON/FLASK] ➔ cd flask/ [~/PYTHON/FLASK/flask] ➔ sudo python ./setup.py install [~/PYTHON/FLASK/flask] ➔ flask --version Flask 0.11.2-dev Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] [~/PYTHON/FLASK/flask] ➔ cd ..
3/ Copier l’application d’exemple :
[~/PYTHON/FLASK] ➔ cp -R flask/examples/minitwit/ .
4/ Création des fichiers d’installation et de configuration :
Ouvrir :
minitwit/requirements.txt
Ajouter :
flask
Ouvrir :
minitwit/wsgi.py
Ajouter :
from minitwit import app as application
Ouvrir :
minitwit/minitwit/minitwit.py
Chercher :
DATABASE = '/tmp/minitwit.db'
Remplacer par :
DATABASE = 'minitwit.db'
Ouvrir :
.gitignore
Chercher et supprimer :
minitwit.db
5/ Création de la base de données Sqlite :
[~/PYTHON/FLASK] ➔ sqlite3 minitwit/minitwit.db < minitwit/minitwit/schema.sql
6/ Test :
[~/PYTHON/FLASK] ➔ export FLASK_APP=minitwit [~/PYTHON/FLASK] ➔ export PYTHONPATH=minitwit [~/PYTHON/FLASK] ➔ flask run * Serving Flask app "minitwit" * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
7/ Initialisation du dépôt local git :
[~/PYTHON/FLASK] ➔ cd minitwit/
- Initialisation du dépôt git :
[~/PYTHON/FLASK/minitwit] ➔ git init . Initialized empty Git repository in /home/sam/PYTHON/FLASK/minitwit/.git/
- Ajouter les fichiers dans le commit :
[~/PYTHON/FLASK/minitwit] ➔ git add -A
- Ajouter le commit :
[~/PYTHON/FLASK/minitwit] ➔ git commit -m "Version 0.0.1" [master (root-commit) 3e1e82a] Version 0.0.1 16 files changed, 783 insertions(+) create mode 100644 .gitignore create mode 100644 MANIFEST.in create mode 100644 README create mode 100644 minitwit/__init__.py create mode 100644 minitwit/minitwit.py create mode 100644 minitwit/schema.sql create mode 100644 minitwit/static/style.css create mode 100644 minitwit/templates/layout.html create mode 100644 minitwit/templates/login.html create mode 100644 minitwit/templates/register.html create mode 100644 minitwit/templates/timeline.html create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tests/test_minitwit.py create mode 100644 wsgi.py [~/PYTHON/FLASK/minitwit] ➔
- Ajouter la branche du dépôt git distant :
[~/PYTHON/FLASK/minitwit] ➔ git remote add gandi git+ssh://7756766@git.dc0.gpaas.net/default.git
- Pousser/Pusher le commit :
[~/PYTHON/FLASK/minitwit] ➔ git push -f gandi master Counting objects: 22, done. Delta compression using up to 4 threads. Compressing objects: 100% (15/15), done. Writing objects: 100% (22/22), 7.66 KiB | 0 bytes/s, done. Total 22 (delta 1), reused 0 (delta 0) To git+ssh://7756766@git.dc0.gpaas.net/default.git * [new branch] master -> master
- Déployer l'application sur l'hôte virtuel 'default' :
[~/PYTHON/FLASK/minitwit] ➔ ssh 7756766@git.dc0.gpaas.net "deploy default.git" initializing builder .................builder ready Vm password: Grabbing terminal Ok -----> Starting new deployment (default - master) -----> Fetching application code -----> Building new application Using Python 2.7 Running virtualenv with interpreter /usr/bin/python2.7 New python executable in /tmp/build.BqsqdbFHZd/local/bin/python2.7 Also creating executable in /tmp/build.BqsqdbFHZd/local/bin/python Installing setuptools............done. Installing pip..................done. DEPRECATION: --no-install, --no-download, --build, and --no-clean are deprecated. See https://github.com/pypa/pip/issues/906. Downloading/unpacking flask (from -r requirements.txt (line 1)) Downloading/unpacking itsdangerous>=0.21 (from flask->-r requirements.txt (line 1)) Running setup.py (path:/tmp/build.BqsqdbFHZd/pip-build/itsdangerous/setup.py) egg_info for package itsdangerous ... minitwit/static/style.css minitwit/templates/ minitwit/templates/layout.html minitwit/templates/login.html minitwit/templates/register.html minitwit/templates/timeline.html tests/ tests/test_minitwit.py sent 31419 bytes received 473 bytes 63784.00 bytes/sec total size is 29770 speedup is 0.93 -----> Build complete -----> Cleaning temporary files
- Test l'application :
http://959c472455.url-de-test.ws/
9/ Capture d'écran :
10/ Liens :
https://wiki.gandi.net/fr/simple/instance/python#exemple_d_application_avec_flask
https://github.com/pallets/flask/tree/master/examples/minitwit
http://rockstarninja.tech/gandisimple-hosting-installation-de-django-1-8/
Comments are closed, but trackbacks and pingbacks are open.