Ai Coding Tools

How to Build a Simple Web App Using Machine Learning in Under 2 Hours

By BTW Team4 min read

How to Build a Simple Web App Using Machine Learning in Under 2 Hours

Building a web app with machine learning might sound daunting, but it doesn't have to be. If you’re an indie hacker or a solo founder, you might be thinking, “I don’t have time for this!” Well, I’m here to tell you that you can actually build a simple web app in under 2 hours using the right tools. In this guide, I’ll walk you through the entire process, share the tools we use, and highlight some of the trade-offs involved.

Prerequisites: What You Need Before You Start

Before diving into the development, make sure you have the following:

  • Basic knowledge of Python: This is crucial as most ML libraries are Python-based.
  • A code editor: I recommend Visual Studio Code or PyCharm.
  • An account on a cloud platform: Google Cloud, AWS, or Heroku are solid choices for hosting.
  • Familiarity with Git: Version control will save you headaches.

Step 1: Choose Your Machine Learning Model

First, you need to decide on a simple machine learning model that fits your web app idea. For instance, if you're building a sentiment analysis tool, a pre-trained model like TextBlob for NLP can be a great start.

Tool Recommendations for ML Models

| Tool | What It Does | Pricing | Best For | Limitations | Our Take | |---------------|------------------------------------------------|-----------------------------|---------------------------|-----------------------------------------|--------------------------------| | TensorFlow | Open-source ML framework for building models | Free | Custom models | Steep learning curve | We use this for custom models. | | scikit-learn | Simple tools for data mining and analysis | Free | Basic ML applications | Limited complex model support | Great for quick prototypes. | | TextBlob | NLP library for processing textual data | Free | Sentiment analysis | Not suitable for large datasets | Perfect for quick sentiment apps. | | Hugging Face | Pre-trained NLP models for various tasks | Free (with paid API limits) | Advanced NLP applications | Requires more setup for fine-tuning | We leverage it for advanced NLP. | | OpenCV | Computer vision library for image processing | Free | Image-based applications | Needs extensive knowledge for complex tasks | We don’t use it for web apps. |

Step 2: Set Up Your Web Framework

Next, you’ll need to pick a web framework to connect your ML model with a user interface. Flask is lightweight and easy to set up, making it ideal for quick projects.

Quick Setup Steps for Flask

  1. Install Flask: pip install Flask
  2. Create a new Python file (e.g., app.py).
  3. Set up a basic Flask app with the following code:
from flask import Flask, request, jsonify
app = Flask(__name__)

@app.route('/predict', methods=['POST'])
def predict():
    data = request.get_json()
    # Call your ML model here
    return jsonify({"prediction": "result"})

if __name__ == '__main__':
    app.run(debug=True)

Step 3: Deploy Your App

You can deploy your app to Heroku or Google Cloud. Here’s a quick overview of deploying to Heroku:

  1. Install the Heroku CLI.
  2. Create a new Heroku app: heroku create your-app-name.
  3. Push your code: git push heroku master.
  4. Open your app: heroku open.

Pricing Breakdown for Hosting

| Platform | Free Tier | Paid Plans | Best For | |---------------|-------------------------------|--------------------------------|---------------------------| | Heroku | Free tier for 550 hours/month | Starts at $7/month | Simple web apps | | Google Cloud | Free tier with credits | Pay-as-you-go pricing | Scalable projects | | AWS | 12-month free tier available | Pay-as-you-go pricing | Complex applications |

Step 4: Create a Simple Frontend

You can use HTML and JavaScript for a basic frontend. Here’s a simple example:

<!DOCTYPE html>
<html>
<head>
    <title>ML Web App</title>
</head>
<body>
    <h1>Predict with ML Model</h1>
    <input type="text" id="inputData">
    <button onclick="makePrediction()">Predict</button>
    <p id="result"></p>

    <script>
        async function makePrediction() {
            const response = await fetch('/predict', {
                method: 'POST',
                body: JSON.stringify({ text: document.getElementById('inputData').value }),
                headers: { 'Content-Type': 'application/json' }
            });
            const data = await response.json();
            document.getElementById('result').innerText = data.prediction;
        }
    </script>
</body>
</html>

Troubleshooting Common Issues

  • App not running: Check if you have all dependencies installed and that your Flask app is running.
  • Model not responding: Ensure your ML model is correctly integrated and that you're sending the right data format.
  • Deployment errors: Make sure your environment variables are set correctly on Heroku or whatever platform you're using.

Conclusion: Start Here

If you want to build a simple web app using machine learning in under 2 hours, start with Flask and a pre-trained model. Focus on a specific use case to keep things manageable. It’s entirely possible to get something functional up and running quickly, even if it means making some sacrifices in terms of features or complexity.

What We Actually Use

In our experience, we use Flask for web frameworks, TensorFlow for custom models, and deploy on Heroku for quick setups. This stack keeps our projects lean and efficient.

Follow Our Building Journey

Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.

Subscribe

Never miss an episode

Subscribe to Built This Week for weekly insights on AI tools, product building, and startup lessons from Ryz Labs.

Subscribe
Ai Coding Tools

10 AI Coding Tools That Will Drastically Reduce Your Debugging Time

10 AI Coding Tools That Will Drastically Reduce Your Debugging Time As a developer, whether you're just starting out or have years of experience, debugging can feel like a neverend

Oct 16, 20265 min read
Ai Coding Tools

10 Common Mistakes When Integrating AI Coding Tools into Your Workflow

10 Common Mistakes When Integrating AI Coding Tools into Your Workflow As developers, we’re always on the lookout for ways to streamline our workflow and boost productivity. Enter

Oct 14, 20264 min read
Ai Coding Tools

5 Myths About AI Coding Tools That Could Hurt Your Development Process

5 Myths About AI Coding Tools That Could Hurt Your Development Process As a solo founder or indie hacker, you might be lured by the promises of AI coding tools that claim to simpli

Oct 13, 20264 min read
Ai Coding Tools

5 Common Mistakes Developers Make When Using AI Coding Tools in 2026

5 Common Mistakes Developers Make When Using AI Coding Tools in 2026 As AI coding tools have become an integral part of a developer's toolkit in 2026, many are still stumbling over

Oct 12, 20264 min read
Ai Coding Tools

5 Myths About AI Coding Tools: What Every Developer Should Know in 2026

5 Myths About AI Coding Tools: What Every Developer Should Know in 2026 As we dive into 2026, the landscape of AI coding tools has evolved significantly, yet many developers still

Oct 11, 20263 min read
Ai Coding Tools

Why AI Coding Assistants Are Overrated for Beginners in 2026

Why AI Coding Assistants Are Overrated for Beginners in 2026 As a solo founder or indie hacker, it’s tempting to think that AI coding assistants are the silver bullet to jumpstart

Oct 10, 20263 min read