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,
let us create a file called app.py, 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. @app.route("/") def main(): return "Congrats for your first Flask app!" # to make it python executable if __name__ == "__main__": app.run()
save the file.
And, now to run it just do,
(myapp)...~/myapp $ python app.py
That is it! Visit http://localhost:5000 and you will see the string Congrats for your first Flask app!