Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Python Networking

You're reading from   Learning Python Networking Utilize Python 3 to get network applications up and running quickly and easily

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781784396008
Length 320 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Network Programming and Python 2. HTTP and Working with the Web FREE CHAPTER 3. APIs in Action 4. Engaging with E-mails 5. Interacting with Remote Systems 6. IP and DNS 7. Programming with Sockets 8. Client and Server Applications 9. Applications for the Web A. Working with Wireshark Index

Hosting in practice

So how does this all work in practice? Well as we saw with Flask, many frameworks come with their own built-in development web servers. However, these are not recommended for use in a production environment as they're generally not designed to be used where security and scalability are important.

Currently, probably the quickest way to host a Python web application with a production quality server is with the Gunicorn server. Using our Flask application from earlier, we can get it up and running using just a few steps. First we install Gunicorn:

$ pip install gunicorn

Next we need to slightly modify our Flask app so that it's use of __builtins__ works correctly under Gunicorn. In your tinyflaskapp.py file, find the line:

objs = __builtins__.__dict__.items()

Change it to:

objs = __builtins__.items()

Now we can run Gunicorn. From within your Flask application project folder, run the following command:

$ gunicorn --bind 0.0.0.0:5000 tinyflaskapp:app

This will launch...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime