Intro to Python
Table of Contents
Python is a popular programming language which can be used for almost any purpose. On the 1&1 Cloud Server platform, most uses of Python involve creating web applications or managing scripts. Learn more about Python, and how to use it on the 1&1 Cloud Server.
Python is installed and running on a Standard Linux installation by default. If your server was created with a Minimal installation, you will need to install and configure Python by hand.
Use Python on the Web
The basics of running Python are covered here in-depth in the official Python documentation.
Many Cloud Server users want to use Python to interact with the web. You may want to run embedded Python scripts in a web page, or use Python as a web application. There are many possible ways to do this. Choosing the right solution for your project will depend on how much complexity you want and need, and the type of project you plan on creating.
Level 1: Small Projects
This solution is best for users who only want to create a few small, lightweight Python scripts, or interact with a web browser as part of testing or learning Python. In this case you want the fastest, easiest way to get Python working in a browser: using the Common Gateway Interface (CGI) to run Python. Consult this article for information on configuring your server to run Python as a CGI Script
Level 2: Web Pages
The middle ground here is users who want to run Python scripts embedded in web pages, or use Python to generate web pages, but who don't necessarily want to build an entire web application. For this scenario, we recommend you use Apache's mod_wsgi to run Python as a web application. See this article for step-by-step instructions to set this up on CentOS 7
Level 3: Web Applications
If you plan to create a complex web application, you will need a more robust system for scaffolding, building out, and testing your application. In this case, we recommend the use of a Python web framework.
The CherryPy web application framework is a good place to start. CherryPy is a minimalist, object-oriented framework which offers a quick, lightweight solution to Python web application development. Click here to learn how to install the CherryPy Python web framework
Manage Python Modules
Modules are a big part of what makes Python such a versatile programming language. Modules allow you to extend and enhance Python, and Python's active open-source community has a substantial library of available modules.
We recommend the use of Pip to install and manage Python packages. Pip is the officially-preferred package manager, and is quick to install and easy to use.
To learn how to install and use Pip on a 1&1 Cloud Server, see our article, Use Pip to Install Python Packages