This repository contains a simple Flask application that demonstrates basic routing, variable rules, form handling, and API creation. This project is a beginner-friendly introduction to Flask, showcasing how to build a web application that can handle different routes, process user input from forms, and return JSON responses through an API.
- Route: '/'
- Method: 'GET'
- Description: The home page of the application, welcoming users with a simple message.
- Route: '/index'
- Method: 'GET'
- Description: A secondary page that provides a welcome message.
- Route: '/success/int:score and /fail/int:score'
- Method: 'GET'
- Description: Dynamic routes that display a message based on a user's score, indicating whether they have passed or failed.
- Route: '/form'
- Method: 'GET', 'POST'
- Description:
- GET: Renders a form where users can input their marks for Maths, Science, and History.
- POST: Calculates the average marks based on the form input. If the average is 50 or above, the user is redirected to the success page; otherwise, they are redirected to the fail page.
- Route: '/api'
- Method: 'POST'
- Description: An API endpoint that receives two values (a and b) in JSON format and returns their sum.
- Clone the Repository
git clone https://github.com/yourusername/flask-app-routing-demo.git cd flask-app-routing-demo
- Install the Dependencies
pip install Flask
- Run the Application
python app.py