Getting Started with Flask on Cloud9

What is Flask?

Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions.

What is Cloud9?

“Cloud9” in Wikipedia: Cloud9 provides an open source integrated development environment in the cloud. It supports more than 40 languages, with class A support for PHP, Ruby, Python, JavaScript/Node.js, and Go. It enables developers to get started with coding immediately with pre-setup environments (workspaces), collaborate with their peers with collaborative coding features, and web development features like live preview and browser compatibility testing available from http://en.wikipedia.org/wiki/Cloud9_IDE

The online documentation of Cloud9 is very rich and helpful. The following help section explains how to get started with the online IDE.

How to install Flask on Cloud9?

The Cloud9 IDE provides developers with a bash terminal, which can be used to install Python packages. To install the Flask package the easy_install python module should be used:

sudo easy_install Flask

Hello World Flask Application

Create an app.py file within your Python application and enter the following code snippet:

Press F5 or click on the Run button to start your Flask application.

Your code is running at https://your-workspace-and-username-goeshere.c9.io.

Important: use os.getenv(PORT, 8080) as the port and os.getenv(IP, 0.0.0.0) as the host in your scripts!

* Running on http://0.0.0.0:8080/

Now you could access your Flask application on the provided url.

  • blipton

    Is it possible to single step python using Cloud9?

    I’m using Cloud9 v3.1.2374 (on the beaglebone black – debian 8.4) I get the error,
    “Language worker could not be loaded; some language features have been disabled”

    And while the run button does seem to execute the python script, I don’t see an option for single stepping. Is this due to the error above? python -V returns ‘2.7.9’, so perhaps cloud9 is configured to use python 3 only?

    Also, Cloud9 forces all saved files to reside in the /var/lib/cloud9 , /opt/cloud9 folder… is there a way to save files elsewhere, like in the home folder?

  • damyanbogoev

    It is possible that some of the Cloud 9 dependencies are installed correctly on your machine. You could try to reinstall it. I have used the cloud-based solution.

    Regarding the Python version used to execute your scripts – I believe you could modify the run configurations and specify the needed version of Python.

    You could set the workspace directory by passing the -w switch (https://github.com/c9/core).