background preloader

Web/Network

Facebook Twitter

Real Python! Blog - Python programming through practical examples. The following is a guest post by Jeff Knupp, author of Writing Idiomatic Python.

Real Python! Blog - Python programming through practical examples

Jeff currently has a Kickstarter campaign running to turn the book into a video series - check it out! A few months ago, I grew tired of the digital goods payment service I used to sell my book and decided to write my own. Two hours later, bull was born. It was a little application written using Flask and Python, which turned out to be an excellent choice for implementation. It started with bare bones functionality: A customer could enter their details in a Stripe JavaScript pop-up, bull would record their email address and create a unique id for the purchase, then associate the user with the content they purchased.

It worked fantastically well. I loved it too, but for a slightly different reason: since bull was running on my web server, I could get a much richer set of analytics than if I had to send customers to a third-party site for payment. The User Model. Flask (A Python Microframework) CherryPy — A Minimalist Python Web Framework. How to Deploy Python WSGI Applications Using a CherryPy Web Server Behind Nginx. Introduction Chances are you found yourself asking one of these questions after reading this tutorial's title: Why should I use CherryPy's pure-Python web server instead of a "real" stand-alone (perhaps C based) one for my WSGI application?

How to Deploy Python WSGI Applications Using a CherryPy Web Server Behind Nginx

CherryPy...Isn't that a framework? What's that got to do with the deployment of my Bottle, Flask etc. based application? There are many good answers and reasons for both. Glossary 1. Bottle: Python Web Framework. Bottle is a fast, simple and lightweight WSGI micro web-framework for Python.

Bottle: Python Web Framework

It is distributed as a single file module and has no dependencies other than the Python Standard Library. Routing: Requests to function-call mapping with support for clean and dynamic URLs.Templates: Fast and pythonic built-in template engine and support for mako, jinja2 and cheetah templates.Utilities: Convenient access to form data, file uploads, cookies, headers and other HTTP-related metadata.Server: Built-in HTTP development server and support for paste, fapws3, bjoern, gae, cherrypy or any other WSGI capable HTTP server. Example: “Hello World” in a bottle from bottle import route, run, template @route('/hello/<name>')def index(name): return template('<b>Hello {{name}}</b>! ', name=name) run(host='localhost', port=8080) Run this script or paste it into a Python console, then point your browser to That’s it. Download and Install User’s Guide Knowledge Base A collection of articles, guides and HOWTOs.

License. Bottle Python framework + Google App Engine. Hi fellas, hope you’re already flying high with GAE and have your own Amazon product store set up after reading my previous post series on how to Set up an Amazon Book Store on Google App Engine!

Bottle Python framework + Google App Engine

GAE supports a number of Python web frameworks. See what the Google App Engine site says: ” Google App Engine supports any framework written in pure Python that speaks CGI (and any WSGI-compliant framework using a CGI adaptor) ” One such framework is ‘Bottle’. Its lightweight (literally, 72 KB only and one file has it all !). Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. Bottle might not be a full fledged framework like Django, Pylons etc. but I may say it is ideal for small to medium applications. In this small article I’ll explain how to use Bottle with Google App Engine.

Lets start with the prerequisites: Google App Engine and Python 2.5: Download and install Python 2.5 from here. and the GAE sdk for Python from here. The Pylons Project Documentation. Tornado Web Server. Twisted. Twisted is an event-driven networking engine written in Python and licensed under the open source ​MIT license. Twisted runs on Python 2 and an ever growing subset also works with Python 3. Twisted makes it easy to implement custom network applications. Here's a TCP server that echoes back everything that's written to it: from twisted.internet import protocol, reactor, endpoints class Echo(protocol.Protocol): def dataReceived(self, data): self.transport.write(data) class EchoFactory(protocol.Factory): def buildProtocol(self, addr): return Echo() endpoints.serverFromString(reactor, "tcp:1234").listen(EchoFactory()) reactor.run() Learn more about ​writing servers, ​writing clients and the ​core networking libraries , including support for SSL, UDP, scheduled events, unit testing infrastructure, and much more.

Twisted includes an event-driven web server. Learn more about ​web application development, ​templates and Twisted's ​HTTP client. Twisted includes a sophisticated IMAP4 client library. Requests: HTTP for Humans. Django. Django by Example. The Django Book.