Can You Develop Web Apps with PyQt?

Understanding the difference between PyQt for desktop apps and Python web frameworks like Flask and Django
Heads up! You've already completed this tutorial.

Can you develop web apps with PyQt? If not, what is the best option for Python web development — Flask or Django? I need to make a RESTful web service on an embedded device.

PyQt is a framework for building desktop applications — programs that run directly on your computer using native GUI elements like windows, buttons, menus, and dialogs. It is not designed for building web applications that run in a browser.

If you need to build a web service or a browser-based interface with Python, you'll want to reach for a web framework instead. The two most popular choices are Flask and Django.

What PyQt Is For

PyQt (and its sibling PySide) lets you create rich, interactive applications that run on the desktop. These are standalone programs — think text editors, data visualization tools, control panels, or anything else that opens in its own window on your operating system.

If you're interested in getting started with desktop app development, the PyQt6 tutorial walks you through everything from creating your first window to building fully featured applications.

PyQt applications are great when you need:

  • A native look and feel on Windows, macOS, or Linux.
  • Direct access to system resources (files, hardware, etc.).
  • A responsive, rich user interface without relying on a browser.

However, PyQt does not generate HTML, does not serve web pages, and does not handle HTTP requests. It operates in a completely different space from web development.

What About Mobile?

Qt (the C++ framework that PyQt wraps) does support mobile platforms like Android and iOS. However, PyQt and PySide do not currently support mobile deployment. If you need a mobile-friendly interface, a web-based approach (accessible through a mobile browser) is often the most practical route when working in Python.

Python Web Frameworks: Flask and Django

For building RESTful APIs or browser-based interfaces in Python, Flask and Django are the standard choices.

Flask

Flask is a lightweight, minimalist web framework. It gives you the basics — routing, request handling, and templating — and lets you add only what you need. This makes it a good fit for:

  • Small to medium web services and APIs.
  • Embedded devices or resource-constrained environments.
  • Projects where you want full control over which components you use.

A minimal Flask API looks like this:

python
from flask import Flask, jsonify

app = Flask(__name__)


@app.route("/api/status")
def status():
    return jsonify({"status": "ok", "message": "Service is running"})


if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)

Run this script and you'll have a working web service responding to requests at http://localhost:5000/api/status.

Flask also supports Jinja2 templates for rendering HTML pages, so you can build simple web interfaces alongside your API if needed.

Django

Django is a full-featured web framework that comes with a lot built in: an ORM (for database access), an admin panel, authentication, form handling, and more. It's a good fit for:

  • Larger web applications with databases and user accounts.
  • Projects where you want many common features available out of the box.
  • Teams that benefit from Django's strong conventions and structure.

Django requires more setup than Flask, but it saves time on larger projects by providing so much functionality by default.

Which Should You Choose?

The choice depends on your project's needs:

Flask Django
Complexity Lightweight, minimal Full-featured, batteries included
Best for APIs, microservices, embedded devices Larger web apps, database-driven sites
Learning curve Gentle Steeper, but well-documented
Flexibility You choose your own components Strong conventions guide your structure

For a RESTful web service on an embedded device — like an IoT gateway running a lightweight Linux distribution — Flask is often the more practical choice. It has a small footprint, minimal dependencies, and is straightforward to deploy in constrained environments.

If your project grows to include a full web interface with user management, database models, and more, Django becomes increasingly appealing.

If you're unsure whether a desktop framework or a web framework is the right fit for your project, our guide on which Python GUI library to choose can help you compare your options.

Combining Desktop and Web

It's worth noting that these approaches aren't mutually exclusive. You might build a Flask-based web API running on your device, and separately build a PyQt desktop application that communicates with that API. This is a common pattern — the web service handles data and logic, while the desktop app provides a rich interface for users who need one.

You could also consider Python frameworks like Streamlit that blur the line between desktop and web, letting you build browser-based data apps with minimal code.

Summary

PyQt is for desktop applications, not web development. For building web services and browser-based interfaces in Python, use Flask or Django. Flask is the lighter option and works well for APIs and embedded systems. Django is more comprehensive and suits larger, database-backed web applications.

If your goal is to build desktop applications with Python, the PyQt6 tutorials are a great place to start. If you're heading down the web development path, both Flask and Django have excellent documentation and active communities to support you.

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak

Bring Your PyQt/PySide Application to Market

Specialized launch support for scientific and engineering software built using Python & Qt.

Find out More

Martin Fitzpatrick

Can You Develop Web Apps with PyQt? was written by Martin Fitzpatrick.

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt. Martin founded PythonGUIs to provide easy to follow GUI programming tutorials to the Python community. He has written a number of popular Python books on the subject.