Have you thought (once again preparing the environment for Python) how it would be great if you didn’t have to set up a working environment from scratch (and even under different operating systems), but could you just sit down and start writing? I accidentally discovered pythonanywhere.com - a service that allows you to conduct development in Python online, right in your browser. Under the cut - a description of the service with pictures and video. I have now configured several Windows and Linux computers, the source code is synchronized via Dropbox, and a microinstance is running on Amazon EC2. All this took a lot of time and is not very convenient - sometimes an idea you want to check “in the field”, and there is no environment tuned with love. What does PythonAnywhere offer?
Before reading a long description, I suggest watching a video briefly about the service:
You can also get acquainted with the performance of the developer Harry Percival at PyCon UK 2011 (good knowledge of English is welcome, but without it you can understand a lot from the presentation): ')
At the end of the speech, Harry didn’t have enough time and he had to run around the hall so that he wouldn’t have the microphone picked up.
We program on Python in the Internet
PythonAnywhere is a Python development environment directly in the browser plus hosting for these projects. If you have a browser and access to the Internet, then you have everything you need. The servers are already configured, they have what you need. Now it is easy to take your development environment with you - start the project on your work computer, and then continue from where you left off, but on your laptop.
IPad owners triumph!
Now, pit drivers can write applications on an iPad, from a phone or even on a “smart” TV (smart TV) as easily as they used to do it on their computers. PythonAnywhere works on iPad and will soon be ready for Android. You can write your programs in a web editor or run a console session from under any modern browser that supports HTML5. You no longer have to set up your own server or pay for setting it up.
What is behind the scenes?
PythonAnywhere uses Amazon (EC2) servers, and we can take full advantage of this approach. For the rapid development of simple applications do not need to pay a penny. And in the case of powerful and resource-intensive tasks, we will pay only for the resources used. In addition, there is integration with DropBox, you can synchronize your data and code. Using the command line makes it easy to work with git, mercurial or subversion projects on GitHub, Bitbucket, and any other public repository.
Python versions 2.6, 2.7 and 3.2 are offered. There are a lot of libraries installed - NumPy, SciPy, Mechanize, BeautifulSoup, pycrypto and others . If this set is not enough, easy_install and pip are available, just use the --user flag, the installation will be done in the .local directory in your home folder. Also added virtualenv and virtualenvwrapper.
Not only Django is supported: Flask, Bottle, web2py - any WSGI web framework will work and most likely is already installed (see batteries ). MySQL and SQLite can be used as databases, the possibility of adding MongoDB and PostgreSQL is being considered.
At the most expensive ($ 10 / month, 2GB for files, SSH) tariff plan, you can host your own domain, and the free tariff gives you a subdomain of the form your-username.pythonanywhere.com. Free tariff with minimal restrictions - 500MB of disk space is available, there is no SSH.
There is an analogue cron - you can schedule the launch of scripts (not just Python) on a schedule. You can see the logs of access and errors of the web server.
Getting Started
Registration does not take much time and immediately after confirming the email address, you can start using the service.
Try Ipython:
Django version 1.3.1. With easy_install, I was able to upgrade Django to the current release 1.4 without any problems:
easy_install --user --upgrade django
Create a new Django project - to do this, go to the Web tab and click the big button “New Django App”:
For a typical Python project without web frameworks, simply create a file in the Files tab and immediately get into the web editor; after editing is finished, the finished file can be saved and immediately launched for execution - a pop-up window will open with a console in which our script will be executed.
Let's continue with Django - we are offered to enter the name of the project and the folder for its storage:
We can use the default folder or save the project to DropBox.
Small nuances related to DropBox:
1) It is advisable that your email in PythonAnywhere matches the email address in DropBox - after all, we will share the folder with the project for “dropbox@pythonanywhere.com” and it should relate this folder to your account. If the email does not match - on the Files tab at the top right click on the link "Connect to DropBox" and specify our email in DropBox. We will be shown in pictures how to share your folder for this service in DropBox.
2) You cannot create a project directly in the ~ / Dropbox directory - you will have to use a subdirectory, like this: ~ / Dropbox / PythonAnywhereProjects / myproject. Technical support hints that this is a temporary phenomenon, saying that the service is currently being developed and they are still limited in capabilities.
3) You can not just delete the shared folder from Dropbox - in this case, it will always remain in PythonAnywhere and you will not be able to delete it even from the console, since we do not have access rights to this. Therefore, first, on the DropBox site, remove access to the shared folder for the user “dropbox@pythonanywhere.com”. After that, the folder will disappear from PythonAnywhere and it can be safely deleted in DropBox.
So, I used synchronization with DropBox:
Checking:
Next, we create the necessary files and edit them in the web editor (or run vim / emacs in the bash console). If you need to create an application in a Django project, use the bash console:
./manage.py startapp myapp
We create a database on the “MySQL” tab, in the same place we set the user password.
Once the files have been created, you need to restart the web server. To do this, use the “Reload web app” button on the “Web” tab.
If you want to run several web applications at the same time - technical support offers to create several accounts with the same email, in the future such an opportunity will appear on one account.
Other uses
Perhaps you will need to consult with a colleague - it is very easy to share any session. To connect, your colleague will not even need to register on the service - just enter his email and he will receive a link to the current console session.
Maybe you have a programming blog with step-by-step examples - you can give readers the opportunity to practice programming right on the blog pages. Just add this code:
Each reader will receive their own console, the state of which will be saved during the transition from page to page.
Or you conduct an offline course on Python programming. It is regrettable to spend the first lesson on waiting, when all the newbies will finish setting up the environment under your leadership. Instead, you can offer to register for PythonAnywhere and after a few minutes, start the training process closely.
You should not get stuck on Python, because there is also a bash-console. For example, we can maintain a permanent SSH connection with a third-party host (the server you serve, etc.). Then if we suddenly need to urgently connect, and for example we will be visiting - the browser will be enough, the console is waiting for us in the state in which we left it.
It's also a good alternative to Google App Engine (and maybe even some paid Python hosting). I'm sure you can come up with other options.