Python online: how to develop without wasting a second to configure

Online Python lets you develop right in your browser without wasting a second setting up an environment. You save a lot of time and you stay focused on your code. In addition, you can code from anywhere you want, as there is a browser. Best of all, you can keep using your favorite operating system without twisting its arm to run Python code!

So online Python development is an incredible opportunity but do you know everything behind it ?!

The Python interpreter

However, the browser does not turn into a Python interpreter. Solutions offering Python online will automatically generate a Python environment on a server. This part is often completely automated and invisible to the developer. It is then possible to modify the code directly on the server with a simple browser. The code already placed in an environment is then ready to be executed. The computer resources used for the execution of the Python code are those of the server and not those of your workstation. The disk space occupied by the code for example is indeed the disk space of the server, even if this is hidden. Server processor and RAM are also utilized by the Python interpreter.

Note that some solutions, such as Vélhost, offer to enrich the environment with modules. The Python community is very active and shares a lot in the form of packages, also known as modules. You just need to use the “import” instruction to use community code. In order to better master your environments, it is recommended to create a dependency file as and when imports are made. This makes it much easier to deploy your developments afterwards. For the “pip” package manager for example, this file is named “requirements.txt” by convention and allows installation of dependencies in one command.

A web server

The Python language continues to grow in popularity and is no longer confined to script development. It is now widely used for web application and website development. In this context, editing Python online requires new bricks and therefore, additional configuration. Fortunately, solutions like Vélhost are already taking care of deploying these bricks and saving developers from tedious configurations.

The main brick is the WSGI (Web Server Gateway Interface) which defines an interface between the Web server and the Web applications coded with the Python language.

Coupled with the WSGI, the Web server (generally Apache2 or NGinx) allows to process HTTP requests by executing Python code. HTTP requests coming from the Internet user’s browser are received by the Web server. This one, uses the WSGI to execute the Python code which goes well and restores the output in the form of a response to the Internet user’s browser.

The web server also provides the static files, but without processing or code execution. This is the case for images, videos and JavaScript or CSS files.

In addition, to respond to HTTP requests, the server must be reachable on the Internet and associated with a domain name. Vélhost offers, for example, an automatically generated URL, already configured and associated with the Web servers. The DNS entry which allows the URL to be associated with the IP of the server is automatically added when the environment is created.

The web server also takes care of the SSL layer to deliver web applications through the HTTPS protocol. Beyond the fact that this protocol is favored by search engines, it is strongly recommended. The HTTPS protocol adds a layer of data encryption which secures exchanges between the server and the user’s browser.

A database

It’s a safe bet that your Web applications will manipulate data and that this data will have to persist! This is the role of the database! Whether PostgreSQL or MariaDB, databases allow Python applications to save and read data from them.

Rare are the online Python-type solutions to offer this brick, but fortunately, this is the case of Vélhost which offers a PostgreSQL database with each environment. Deployed and already configured, the database is then accessible from the Python environment.

Private mode

The solutions for editing Python code online are mostly geared towards sharing snippets. In this sense, they are not really suitable for classic web application development, because they do not allow, among other things, to protect access to code.

This is not the case with Vélhost, which offers private environments by design. Each user has a dedicated server through a secure account. Python code is only accessible to the authenticated developer who writed it.

Of course, the Web application is accessible on the Internet thanks to the generated URL.

Version management

It is hardly possible to develop without code versionning. Whether it is to work in a team or simply to secure your code, it is imperative to use a version management tool.

The principle is that each code modification is kept and stored on a remote server. Thus, code versionning is ensured and teamwork is possible. It can be very practical in the case of a regression. If a bug appears, the analysis of the latest modifications to the code very often pays off.

As a team, code review is now very widespread. The author submits his code for review to other developers on the team. Without their validations, the code is not deployed in production. It goes without saying that this kind of practice is not possible without a successful code manager.

The most commonly used manager is undoubtedly GIT and it is also the tool chosen by Vélhost. Although essential, versioning is rarely available on Python online solutions.

A terminal

The terminal is the interface to execute command lines. Widely used for configuring servers that do not have a graphical interface, the terminal can also be used to maintain applications. In the most common uses, it is used to install project dependencies, perform database migrations or launch scripts.

On a Python Django project for example, the terminal is needed to initialize the project, create the applications and create the super user. Then, it is useful for applying model changes to the database (“migrations”). It can also be useful for injecting datasets.

The logs

A log is data associated with a date and a time. This data is thus stored in order to create a log of events occurring within an application. Typically, processing errors are written to a file for later analysis. It is also possible to send logs to a log server. The latter is responsible for centralizing the management of logs in order to analyze them and identify correlations.

In Python, the “logging” module allows you to easily set up a logging system. A simple logger.info('My message') instruction will log an event in the output or in a file depending on the configuration of the project.

In a online development context, it is also possible to view these log files. Often split in two, info on one side and errors on the other, these files are essential for verifying the proper functioning of a web application.

Backups

It cannot be said enough, but there are 10 types of people in the world, which have already lost data and those who will lose it!

The backup is therefore a insurance, that of leaving quickly and not losing hours of work.

In the development phase, the code is in principle secured by the use of a version manager. But there are often data sets that can be lost.

To avoid these mishaps, it is a good omen to make regular backups of all files and the database.

Development solutions in Python online do not necessarily offer this possibility. Vélhost allows this with a single click and allows you to obtain an archive of your files and your database. This archive can be downloaded directly to your computer to possibly be deployed later or even elsewhere.

Conclusion

The bricks necessary for development in Python, in particular for the Web, are therefore numerous and can prove complex and time-consuming to set up. Plus, their deployments can take you away from your code, your goals, and your favorite operating system.

It is therefore entirely appropriate to rely on solutions offering ready-to-use environments.

However, check that the envisaged solution ticks all the boxes according to your needs.

Finally, give preference to open solutions, that is to say those where it is possible to recover your code and your data at any time.