A friend called me the other day wanting to learn more about putting together a Flask application. After brewing a good Catimor coffee variety from Dominican Republic I decided to get a sample Flask code for starters and share it with everybody.

This Flask application includes:

  1. Importing the Flask class from the flask module.
  2. Creating a Flask application instance with app = Flask(__name__).
  3. Defining a route / using the @app.route() decorator and a corresponding view function (index()) that returns a simple message.
  4. Running the Flask application with app.run().

You can save this code to a Python file (e.g., app.py) and run it using Python. The Flask development server will start, and you can access the application in your web browser at http://localhost:5000/.

from flask import Flask
# Create a Flask application instance
app = Flask(__name__)
# Define a route and its corresponding view function
def index():
    return 'Hello, World!'
# Run the Flask application
if __name__ == '__main__':

As usual, you can contact me if you have any questions or want to collaborate.

Leave a comment

Your email address will not be published. Required fields are marked *