Updated: January, 2016
My Path To Python Web Development: Stuff I Wish I Knew Sooner…
I used Python for several years before I deployed my first Python web application on the internet. I wasn’t a stranger to web development either – I had been working with PHP (for personal stuff) and ASP.net (for work) before. Finding a hosting environment to *develop* a Python web application is fairly easy – for those who have not tried it, most Python web frameworks include a development server which can run on your desktop. This should be enough to get you through developing a good working prototype of your application. But the process of finding a good (ideally free) python host to publish your first project to the web has few quirks that this article will help you overcome.
In my quest for a good shared hosting option for Python, my first call was to my current hosting company who supported my LAMP (Linux / Apache / MySQL / PHP) applications. After a short chat with their customer service team, it was apparent Python wasn’t a good fit with their program. You can wall off PHP users on the same server from each other by limiting their access via a highly structured management console. Python applications need deeper access to the underlying system that a PHP script – which requires a larger investment in hosting and server management. This became a roadblock: while Python is a much more powerful language than PHP, PHP / LAMP offered a cheaper and simpler deployment path for a newbie.
My original PHP host wanted about $50/month for a low-end VPS – or about $600/year. While we found better options (free python hosting, profiled below), this isn’t as outrageous as it sounds. If you’re building a serious project with commercial ambitions, developer time is often more precious than cash. If I spend more than 30 minutes a month maintaining “the box” or (worse) dealing with an outage, I’ve immediately blown through my entire savings from a cheap hosting plan.
Fortunately, there are better options. We’re splitting these into two groups – first, several options for truly free python hosting (as in beer). Second, since most of the free python hosting plans are designed to coax you into upgrading into a low-cost paid plan, we also will talk about ultra-low cost ($5 – $10/month) options that offer additional services helpful for launching a commercial project (such as hosting a project on your own domain, better email support, and integrating in other packages like WordPress, PostGres, and PHP).
Incidentally, everyone profiled in this article is a solid company, active Python community participant, and has simplified their model to the point where new developer can pick it up. I strongly prefer to use hosting providers that have embraced Python and staff their help desk teams with people who have some Python exposure or coding experience; it makes resolving problems with a Python application much easier. Consider this table-stakes.
Free Hosting Options
[Updated January 2016] Sadly, this list has shrunk since our last revision. We’re going to walk through three options here, one of which remains a very good choice, the other two having attached significant strings to their offerings. Our fourth plan isn’t free anymore…
If anyone good connections in Washington DC and wants to stimulate the economy, please propose they fund a GARP bailout (Government Assistance for Running Python); free Python servers for everyone! Ok, back to the real options…
First up, PythonAnywhere. They have a beginner account plan that is free (as in beer) and gives you the basics required to get your first web application online and visible. The plan includes use of a subdomain (<user-name>.pythonanywhere.com) for hosting your project (another $20 saved). The configuration and setup process is managed through a nice simple console; the free plan includes easy setup for several major web frameworks (Django, web2py, flask, bottle) and supports both Python 2 (2.7) and 3 (3.3, 3.4). You’re allowed to host one low-bandwidth web application for free, additional applications require an upgrade to a paid plan. The free plan comes with access to a MySQL database; PostGres is available but requires upgrading to a paid plan.
After looking at the providers, PythonAnywhere (click here for details & signup) emerged as my recommendation for hobby projects and first time users. The console makes it easy to get started, there is a high level of support and guidance, and you get “all the stuff” required to get going on a real project without any really annoying strings. Paid plans are very reasonable – the first one starts at $5/month and expands the capabilities of your first application; the second costs $12/month (better value) and lets you to host multiple projects using that account. But best of all, free is actually free here: you can run a single application on their free plan as a fully functional, continuously operating Python website / service for an indefinite time.
[Update – Educators: PythonAnywhere has a special program for educators which simplifies managing environments for a large class of students. Details provided here.]
One potential alternative is Heroku’s free tier, which announced a pricing change. They simplified things: you can get a free dyno (virtual instance that runs a web application) with the capability of handling some worker processing as well. This is enough to demo a small project and is good preparation for people who intend to use Heroko professionally. One very nice plus: Heroku is closely integrated with Git – allowing you to deploy an application directly from your Git repository. You can scale the application by adding additional processors, which will cost you a modest amount of money.
However, they’ve gotten a bit aggressive in their strategy for upgrading people to their $7 “hobbyist” tier. Their free plans are only able to operate online for 18 out of every 24 hours. In practical terms, since the web has a global audience, your project will be offline for at least part of the day. This also very impractical if you’re hoping to get your project listed in Google’s search results; they often index content on sub-domains, but are unlikely to rank a project that’s offline for 6 hours per day very highly in their results. So while Heroku is an decent option if you want to do a quick demo or show a potential employer you can use Heroku, consider using other Python hosting plans for long term personal projects.
OpenShift is another possible option; they are maintained by the original red hat board and offer a cloud service platform. They provide the ability to run three small applications on their platform within the scope of the free plan. However, their pricing scheme seems to have learned from Heroku’s example and includes an “application idling” provision within the free plan which will pause your site if there’s a significant gap in traffic (suggestion solution being to upgrade to a paid plan). It’s potentially worth checking out if you want to use their platform for larger projects.
Google App Engine was on our list (and ranked highly) but their free offering seems to have disappeared into a “give us your credit card and we’ll give you $300 of free services for 60 days” deal. Unfortunately too rich for my hobbyist blood. A pity, since their prior deal let you to host up to 10 small websites on their platform and was great place to get started. Google has historically been Python-friendly and they use it for many projects internally.
Low Cost Python Hosting Options
Since the common theme above is your free Python hosting provider will inevitably push you to upgrade to a paid plan for your project to reach full potential, lets look at why you may want to consider going with a low-cost paid plan to begin with. In essence, if your project or website will be used for professional or commercial purposes (even showing advertisements), it’s often worth buying your own domain (<$20) and paying for a low-cost python hosting plan that offers you some additional tools that can help grow your project.
My wife and I knew from the start that our web hosting plan would be used for professional portfolios (blog, resume, brochure) and to run a small business (online games & puzzles). While Python is my weapon of choice for serious development, there’s a huge variety of marketing and publishing/communications tools built up around WordPress and PHP that simplify running an online business. Your biggest investment is going to be time – not cash – and I’m a fan of not reinventing the wheel for basic tasks. We looked at several providers and selected a Python-friendly shared hosting plan at Webfaction (starts at $10 / month). The decision came down to saving time and simplifying technical support – my area of expertise is development and analysis, we needed a vendor who could simplify server management and the environment setup/configuration side of things.
Webfaction offers a shared hosting environment for Python; you get access to most of a Linux shell (similar to a VPS) with Python and many major building blocks and databases already installed (django, flask, PostGres, MySQL, most python web frameworks, etc.). These run behind an nginx server (nearly bulletproof) with the ability to serve static content directly from nginx (faster and reduces the load on your Python app). In addition to Python, they provide installers for common web applications written in other languages – this ranges from blogging/content management (WordPress, Joomla, Drupal) to node.js and Rails. You’ve got good shell access to the server and can set up your own scripts and tools – very similar to a dedicated VPS. Tech support is very Python friendly; Webfaction is focused on the developer community and many of their support team have significant Python experience.
Unlike the free plans, we haven’t had to worry much about service limitations either. You can set up an unlimited number of domains/projects: I currently manage ten sites from this account. Then there’s email – they have a nice webmail service and good routing options, so you can give everyone on the team for a project a site-specific email address to use for communications with customers and partners (looks way more professional). From a bandwidth and resource perspective, they offer a nice large quota – our largest project last month served 5 MM hits and we’ve barely scratched our quota (used about 2%). Finally, if we are lucky enough to need a dedicated server (eg. massive traffic), we’re still building our site using a standard Linux environment with common databases (MySQL, Postgres) so we can scale it up to a private VPS without having to strip out platform specific junk.
It’s very easy to assemble websites using multiple technologies. For example, this blog uses WordPress (since it IS a blog) but certain paths lead into a Python web application which serves up an interactive analysis tool. Our gaming site is built around Python but has a WordPress blog sitting off to one site for relatively static content and a couple of plugins; this allowed us to focus our efforts and development time on building out the gaming side. WordPress is very helpful from a promotional perspective (lots of plugins and themes) and is simple enough we can offload marketing-related tasks to non-developers. This helps “get more things done” by simplifying business and communications activities and allows your developers to focus their efforts on product, content, and coding.
So the outcome of all this is we found plan that allows us to manage 10 websites (with lots of traffic) with excellent technical support, easy access to marketing & communication tools, and plenty of room to grow for $10 / month. I’ve been using Webfaction for over three years across multiple projects (gaming sites, web apps, blogs) and have been very happy with their service. For more information about Webfaction, including a free trial offer (lets you kick the tires before committing), click here (link to the free trial offer).