SlideServe
Menu
Préférences
© SlideServe · v2026

Rémi Delon

mckile avatar
8 diapositives · 354 Views · Oct 21, 2014

CherryPy: Dynamic websites with Python. http://www.cherrypy.org. Rémi Delon. remi@cherrypy.org. What is CherryPy ?. Pure Python (no C) tool for developing dynamic websites Works with python 2.1, 2.2, 2.3, Jython Runs everywhere python runs (Linux, Windows, …) Works like a compiler:

Rémi Delon - slide 1
01 / 8Rémi Delon
1 / 17

Télécharger la présentation

Rémi Delon
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. CherryPy: Dynamic websites with Python http://www.cherrypy.org Rémi Delon remi@cherrypy.org

  2. What is CherryPy ? • Pure Python (no C) tool for developing dynamic websites • Works with python 2.1, 2.2, 2.3, Jython • Runs everywhere python runs (Linux, Windows, …) • Works like a compiler: • Source files (.cpy) -> Single executable (.py) • Source files use : • python + a few extra keywords + templating language

  3. Sample source file Root.cpy CherryClass Root: view: def index(self): return “”” <html><body> Hello, world </html></body> “”” [remi@boa] cherrypy.py Root.cpy [remi@boa] python RootServer.py [….] Serving HTTP on socket port: 8000 Browser -> http://localhost:8000

  4. CherryClass Root: mask: def index(self): <html><body> Hello, world </html></body>

  5. CherryClass Root: mask: def index(self): <html><body> <py-exec=“a=2”> <py-for=“i,j in [(0,0),(1,0),(2,2)]”> Sum: <py-eval=“i+j+a”><br> </py-for> <py-code=“ import smtplib if 0==0: b=2 “> </html></body>

  6. Sample source file for a dynamic site (also using OOP) import time CherryClass Design: mask: def header(self): <html><body> def footer(self): </body></html> CherryClass Root(Design): function: def getTime(self): return time.strftime('%H:%M:%S') mask: def index(self, myName=“world”): <py-eval=“self.header()”> Hello, <py-eval=“myName”><br> The time is: <py-eval=“self.getTime()”> <form action=“index”> Enter your name: <input type=text name=myName> <input type=submit> </form> <py-eval=“self.footer()”>

  7. Key properties of CherryPy • Everything we love about Python is still there: • Clean syntax • Powerful constructs. ex: for i,j in [(0,0),(1,2)] • OOP • Standard library • … • No unneeded extra code in the source files • Very fast (thanks to compiler approach) • Easy to deploy (just one file) + all the features you would expect from a serious application server: • Database connectivity • Can be run behind another webserver (Apache, …) • Load-balancing • Cacheing, Sessions, Http and cookie-based authentication, Form handling • XML-RPC • HTTP server supports SSL, threading, forking, process pooling, … • Good documentation + can be used as an XML/XSL framework if you want

  8. Questions ? http://www.cherrypy.org remi@cherrypy.org