This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Creating an application


How to create an application

After forking the Flickr Person demo application, you will see that it has two important files:

  • createTasks.py
  • template.html

createTasks.py is the script that creates for us the application in PyBossa and also the tasks for it. It will also use the Flickr API to get the latest 20 published photos in Flickr to create the tasks, so this script is really important for creating an application and its tasks.

template.html  is the Task Presenter, or in other words, the skeleton or view of the task that Pybossa will render for the volunteers. template.html will get the task input files: the Flickr photo URLs, and render them for the volunteer so he can see it and answer the question: do you see a human in this photo? The template also provides the action buttons or input fields that the user will need to submit his answer.

Now that we have a more clear idea about the two key elements of the application, let's focus in this challenge in the createTasks.py script.

Creating an application

The script is coded in Python, however you do not have to use this language as PyBossa provides a RestFUL API that can be used from any programming language: PHP, Perl, Java, etc.

The script shows all the possible actions that you can do with the PyBossa API:

  • Create
  • Read
  • Update
  • Delete

These methods, usually known as CRUD, can be used with Applications, Tasks, and TaskRuns (the answers from the users).

In order to use the API we will need an API-KEY to authenticate our actions within the PyBossa service. Thus, if you do not have created a PyBossa account already, go to pybossa.com and sign in with your Twitter or Facebook account (or if you prefer create a PyBossa account). After signing in, you will see in your profile an API-KEY. This key will be used to authenticate and authorize actions in the PyBossa API.

The createTasks.py script has several functions or methods that show how you can create an application, delete or update it. The script follows the next steps:

  1. Check if the application is already registered in PyBossa (Read method)
  2. If the application exists, delete it (Delete method)
  3. Else create it with a typo in the name (Create method)
  4. Finally, Update the recentely created application to fix the typo (Update method)
  5. Create the tasks.

As you will see the application has a typo in the name or description, so the update method is just an excuse to show you how you can update an application without having to delete it and then re-create it (deleting an application will delete all the tasks and its associated answers, be careful!).

When the application is created, you should provide an HTML+JS template to present the task to the users. As we have explained in the introduction of this challenge, the application has two main files: the createTasks.py file, and the template.html.

The template is just the skeleton where we will load the Flickr images. As the script will get for us the Flickr URL photo links, we will only have to change via JavaScript (we use jQuery to simplify the development) the <img src=target> with the task one.

Once we have created an application, we can update the template to fix an error or to improve the presentation of the information to the users, so they can interact with your application in a better and simplified way.

The challenge

Now that we have a better idea about how we can create an application, the goal will be to change the name of the application, short name (or slug) and its description in the createTasks.py script. Save the changes and commit then to your Github fork, so you can share it here with us.

Task Discussion