First app with Flask!

From our previous tutorial, we installed the Flask micro web framework in our system, now let us create a folder saying myapp and activate the virtualenvwrapper environment myapp which we created in our getting started tutorial. To activate myapp, we do it by running the command,

...~/myapp $ workon myapp

that should make the command line look like,

(myapp)...~/myapp $

let us create a file called, and then put the following content in it,

from flask import Flask
app = Flask(__name__)
# simple root routing decorator and the main function will just return
# a String to the browser.
def main():
    return "Congrats for your first Flask app!"

# to make it python executable
if __name__ == "__main__":

save the file.

And, now to run it just do,

(myapp)...~/myapp $ python

That is it! Visit http://localhost:5000 and you will see the string Congrats for your first Flask app!