Are you a Tamil-speaking developer eager to learn Flask, a popular Python web framework? You've come to the right place! This comprehensive Flask tutorial in Tamil will guide you through the basics of Flask, helping you build web applications with ease. Let's dive right in!
What is Flask?
Flask is a lightweight and flexible Python web framework that is perfect for building small to medium-sized web applications. It's easy to get started with Flask due to its simplicity and minimalistic approach. Flask is built with a focus on simplicity and fine-grained control, making it an excellent choice for both beginners and experienced developers.
Setting up Flask Development Environment
Before we start coding, let's set up our development environment. You'll need to have Python and pip installed on your system. If you haven't installed them yet, you can download Python from the official website and install pip along with it. Once you have Python and pip, you can install Flask using the following command:

pip install flask
Hello, World! in Flask
Now that we have Flask installed, let's create our first Flask application. Create a new file named `app.py` and add the following code:
```python from flask import Flask app = Flask(__name__) @app.route('/') def hello(): return "Hello, World!" if __name__ == '__main__': app.run(debug=True) ```
Run the application using the command `python app.py`. Open your web browser and navigate to
Understanding Flask Routes
In the previous example, we defined a route decorator `@app.route('/')` that maps the specified route ('/') to the `hello()` function. Flask uses these route decorators to connect URLs to Python functions. Here's an example of defining multiple routes:

```python @app.route('/about') def about(): return "This is the about page." @app.route('/contact') def contact(): return "Contact us at info@example.com" ```
Now, if you navigate to
Passing Data with Flask
Flask allows you to pass data to your templates and render HTML pages. Let's create a simple template and pass some data to it. First, create a new folder named `templates` in the same directory as `app.py`. Inside the `templates` folder, create a new file named `index.html` with the following content:
```html
{{ title }}
{{ message }}

```
Now, update your `app.py` file to pass data to the template:
```python from flask import Flask, render_template app = Flask(__name__) @app.route('/') def index(): return render_template('index.html', title='Flask Tutorial', message='Welcome to our Flask tutorial in Tamil!') if __name__ == '__main__': app.run(debug=True) ```
Run the application again, and you should see the title and message displayed on the page.
Handling Form Data with Flask
Flask provides tools for handling form data using the `request` object. Let's create a simple form to accept user input. Update your `index.html` file with the following content:
```html
{{ title }}
{% if message %}{{ message }}
{% endif %} ```
Add the following code to your `app.py` file to handle the form submission:
```python from flask import Flask, render_template, request app = Flask(__name__) @app.route('/') def index(): return render_template('index.html', title='Flask Tutorial', message='') @app.route('/greet', methods=['POST']) def greet(): name = request.form.get('name') message = f"வணக்கம், {name}!" if name else "Please enter your name." return render_template('index.html', title='Flask Tutorial', message=message) if __name__ == '__main__': app.run(debug=True) ```
Now, when you submit the form with your name, you'll see the greeting message displayed on the page.
Conclusion
In this Flask tutorial in Tamil, we've covered the basics of Flask, from setting up the development environment to handling form data. You now have a solid foundation to build upon and create more complex web applications using Flask. Happy coding!






















