An age prediction web app where users enter a name and the server retrieves an estimated age using an external API. The project focuses on backend fundamentals, API integration, and building interactive web applications.
A Flask-based web application that estimates a person's age using their name. The application integrates with the Agify API, which analyzes datasets of names and ages to return a predicted average age. This project demonstrates backend development, API integration, routing, and frontend interaction.
This project allows users to input a name and receive an estimated age. The backend server communicates with an external API that processes statistical data and returns a predicted age. The result is then displayed on a dynamic webpage.
The purpose of this project is to demonstrate how web servers interact with APIs and how data flows between the frontend and backend of a web application.
- A user enters a name into the input field.
- JavaScript captures the form submission.
- The browser redirects the request to the route
/name/<name>. - The Flask backend receives the request.
- The server sends a GET request to the Agify API.
- The API processes the name using its dataset.
- A JSON response containing the predicted age is returned.
- Flask renders the result using a template.
Example request to the API:
https://api.agify.io?name=emma
Example response:
{ "name": "emma", "age": 28, "count": 15000 }
The returned age represents the average predicted age for people with that name based on available data.
Backend
- Python
- Flask
- Requests library
Frontend
- HTML
- CSS
- JavaScript
External Service
- Agify API
Concepts Demonstrated
- REST API integration
- JSON data handling
- Dynamic routing
- Template rendering
- Client-server communication
project/ │ ├── app.py │ ├── templates/ │ ├── home.html │ └── index.html │ ├── static/ │ ├── style.css │ └── script.js │ └── README.md
- Clone the repository
git clone https://github.com/yourusername/age-predictor.git
- Navigate into the project directory
cd age-predictor
- Install required dependencies
pip install flask requests
- Run the application
python app.py
- Open the application in your browser
User Input → JavaScript Form Handler → Flask Route → API Request → JSON Response → Render Template → Display Result
- Predicts age using a name
- Clean user interface
- Dynamic routing
- API data integration
- Lightweight backend server
- Simple and interactive frontend
Through this project you can learn:
- How Flask web servers work
- How to connect applications with third-party APIs
- Handling HTTP requests and responses
- Rendering dynamic templates
- Structuring a small full-stack project
- Add gender prediction
- Add nationality prediction
- Add error handling
- Deploy the application to the cloud
Agify API
https://agify.io
Agify predicts age using aggregated statistical data from names across different regions and datasets. Agify provides free access of API for education and Learning .
This project is open-source and intended for educational and learning purposes.