Outils pour utilisateurs

Outils du site


dev:frameworks:pyramid:installer

Ceci est une ancienne révision du document !


Installation de Pyramid

Pour éviter tout conflit on crée d'abord un environnement virtuel avec virtualenv:

$ virtualenv --python=/ ~/developpement/test-pyramid/env_test-pyramid

On active l'environnement virtuel, puis on lance l'installation de pyramid:

$ source ~/developpement/test-pyramid/env_test-pyramid/bin/activate
$ pip install pyramid==1.6

Hello Pyramid

Avec un éditeur de texte, créer un fichier hello.py avec le contenu suivant:

from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
 
def hello_world(request):
    return Response('Hello %(name)s!' % request.matchdict)
 
if __name__ == '__main__':
    conf = Configurator()
    conf.add_route('hello', '/hello/{name}')
    conf.add_view(hello_world, route_name='hello')
    app = conf.make_wsgi_app()
    server = make_server('0.0.0.0', 8099, app)
    server.serve_forever()

Lancer l’exécution du serveur:

$ python ./hello.py

Puis saisir l'URL suivante de le navigateur web: http://localhost:8099/hello/world

dev/frameworks/pyramid/installer.1454342894.txt.gz · Dernière modification : 2021/02/01 21:51 (modification externe)