QR Redirector App

import uvicorn
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
import qrcode
from io import BytesIO
from base64 import b64encode

app = FastAPI()

@app.get("/", response_class=HTMLResponse)
async def read_root(request: Request):
    user_agent = request.headers.get('user-agent')
    redirect_url = 'https://play.google.com/store/apps/details?id=example' if 'Android' in user_agent \
        else 'https://apps.apple.com/us/app/example/id1234567890'
    qr = qrcode.QRCode(

About this template

The QR Redirector App now asks for the iOS and Android URLs on startup, detects the user's device type, and displays a QR code that redirects to the respective store URL within an HTML page.

Introduction to the QR Redirector App Template

Welcome to the QR Redirector App template! This template is designed to help you create a web application that dynamically generates a QR code. When scanned, the QR code will redirect users to a specific URL based on their device type—either the Google Play Store for Android devices or the Apple App Store for iOS devices. This is particularly useful for marketing campaigns or any scenario where you want to provide a quick and easy way for users to download your app.

Getting Started with the Template

To begin using this template, simply click on "Start with this Template" on the Lazy platform. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy, paste, or delete any code manually.

Test: Deploying the App

Once you have started with the template, the next step is to deploy the app to see it in action. Press the "Test" button on the Lazy platform. This will initiate the deployment process and launch the Lazy CLI. The deployment process is handled entirely by Lazy, so you don't need to worry about setting up your environment or installing any libraries.

Using the App

After pressing the "Test" button and the app is deployed, Lazy will provide you with a dedicated server link. You can use this link to access the web interface of the QR Redirector App. The interface will display a QR code that users can scan with their mobile devices. The QR code will redirect them to the appropriate app store based on their device's user-agent.

If you are using FastAPI, which is the case with this template, Lazy will also provide a link to the FastAPI documentation. This can be useful if you want to understand more about how the API works or if you plan to extend the functionality of the app in the future.

Integrating the App

If you wish to integrate the QR Redirector App into another service or frontend, you can use the server link provided by Lazy. For example, you might want to embed the QR code on your website or within an email campaign. To do this, you can include the following sample HTML code snippet where you want the QR code to appear:

<iframe src="YOUR_LAZY_SERVER_LINK" width="300" height="300"></iframe>

Replace "YOUR_LAZY_SERVER_LINK" with the actual link provided by Lazy. This will embed the QR code generator directly into your chosen platform, allowing users to scan the QR code without having to navigate away from your website or email.

Remember, all the steps listed above are mandatory to run and integrate the template. No additional environment variables or user input through the CLI are required for this template, so you can focus on using and integrating the app right away.

By following these steps, you can quickly set up and deploy the QR Redirector App using the Lazy platform, providing a seamless experience for your users to download your app from the correct app store.

Last published
May 18, 2024

More templates like this

FALLBACK | Flask, HTML, JS and Tailwind Based Website

This is a good starting point for styled website. It has a header, footer. Has Tailwind and Flowbite loaded so you can build nice looking pages from here.



WebGen: A web development app that combines front-end and back-end skills to generate code based on user requests.

React JS

FALLBACK | Flask, HTML, JS and Tailwind Based Website

This is a good starting point for styled website. It has a header, footer and Tailwind loaded so you can build nice looking pages from here.

QR Redirector App