Published in 20:44 of 08/09/2012 by

Published in 20:44 of 08/09/2012


web2py on PythonAnywhere


web2py is a powerful and easy to learn Python web framework, it is a full stack framework which means that you are going to find built in features for almost aeverything you need on web development.

web2py is safe, fast, smart and it simply lets you to get things done!

(of course this is a biased oppinion :P )

Python Anywhere

Python is great! everybody loves it. Now imagine the possibility to have your Python Environment on the cloud, on that environment Python from version 2.5 to 3.2, in the same environment you have a mysql shell and a bash shell where you can use git, hg, unzip, tar, wget and many other *unix features and additionally you have a very nice cron-like scheduler to program python/sh tasks.

The best feature ever is the ability to share the same Console with many people and the ability to save the console session even if you loggout or need to switch form computer to tablet.

Thats ! The best place to learn, test, develop with your team and of course, the best place to host your websites and services!

web2py app on PythonAnywhere

  1. Register on PythonAnywhere for a free or payed account
    Python Anywhere Offers some plans:
  1. On Dashboard create a new web2py application PAWEB
  1. Choose an admin password and click next to wait while your web2py app is created This Process can take a bit of time, PA will download and unzip a new web2py stable source
    and also it will configure your pointing to your web2py root folder.

When it finished you will see this screen: PANok

Now you have a running web2py application running on

Your appp should look like this:

PythonAnywhere tabs

  1. Files tab - you can browse, edit, create, upload and connect to a DropBox account PANtabs
  1. web tab - You can reload your apache server, see your logs or edit your file panweb
  1. Schedule tab - Here you can schedule task to run hourly or daily, tasks are sh or python scripts PANTASK
  1. Mysql tab - here you can create a database and change passowrd, also check credentials for connection panmysql
  1. Consoles - the most powerful feature you can start and share consoles panconcole

Lets code!

Now that your are familiar with PythonAnywhere we can create our app, I am going to show how to do that using two approaches

Using web2py web IDE for coding and management

  1. Go to your app - Note the https, it is necessary to access the web2py admin

Thats the web2py admin interface, put the password you set on app install step

  1. Create a new simple app named app1

  1. Web2py will let you admin your app, edit files, create database models using the web interface

  1. Click in edit next to under models section

Look for this line of code db = DAL('sqlite://storage.sqlite') now we are going to change it
as it is connecting to a sqlite database, we want to change it to our mysql database

You can go to MYSQL tab on PythonAnywhere dashboard and create a new Mysql Databse, and also set a new password for Mysql user, create a database calles app1 and it will be accessible using yourname$app1 Dont forget to set a new MYSQL PASSWORD

  1. Lets change our db connection

In your https://**yourname**
You will change:
THIS db = DAL('sqlite://storage.sqlite')
IN TO THIS: db = DAL('mysql://youname:yourMYSQLPassowrd@mysql.server/yourname$app1')

  1. Click in the save icon or hit ctrl+S and then return to admin clicking edit in the main menu

  2. Now you will see the following button next to models section

  3. Click in database administration or go to https://**yourname**

  4. It is the web2py appadmin, it allows you to see the tables defined in your models and existing in your db

  • O Natal Animal 2013 está no ar in Home · 23:24 of 12/10/2013
  • Desenvolvendo protótipos para startups com Python e web2py in web2py · 20:25 of 11/19/2013
  • Gravando logs de aplicativos web2py in web2py · 00:29 of 01/21/2013

  • comments powered by Disqus Go Top