Jump to content

Flask App Serving The Same Template Regardless Of Client

TheCoder2019
Go to solution Solved by RockSolid1106,

I went through your code on the repl and it seems to be working?

 

Website URL hidden because it was previously moderated.

Spoiler

On my iPhone:

 

DDFDBAC0-E39A-43DB-BC24-F7C14E815488.jpeg.96d7ba1b57b80ae36157394da50835d4.jpeg

 

Desktop:

image.thumb.png.88dd0198e495efb28ce758465f99f2e3.png

 

So, I have a flask app that should have 2 templates being returned, but it only returns one: home.html

For mobile, I want a separate template returned: home_mobile.html

 

Here is the flask part of the root directory:

@app.route('/', methods=['GET', 'POST'])
def home():
      
    user_agent = request.headers.get('User-Agent')
    user_agent = user_agent.lower()
    
    if "iphone" in user_agent:
        return render_template('home_mobile.html')
    elif "android" in user_agent:
        return render_template('home_mobile.html')
    else:
        return render_template('home.html')

What I imported:

import os
from flask import Flask, Response, render_template, request
from threading import Thread

app = Flask(__name__)

 

Can someone help me?

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

I went through your code on the repl and it seems to be working?

 

Website URL hidden because it was previously moderated.

Spoiler

On my iPhone:

 

DDFDBAC0-E39A-43DB-BC24-F7C14E815488.jpeg.96d7ba1b57b80ae36157394da50835d4.jpeg

 

Desktop:

image.thumb.png.88dd0198e495efb28ce758465f99f2e3.png

 

Edited by RockSolid1106
On 4/5/2024 at 10:13 PM, LAwLz said:

I am getting pretty fucking sick and tired of the "watch something else" responses. It's such a cop out answer because you could say that about basically anything, and it doesn't address the actual complaints. People use it as some kind of card they pull when they can't actually respond to the criticism raised but they still feel like they need to defend some company/person. If you don't like this thread then stop reading it. See how stupid it is? It's basically like telling someone "shut the fuck up". It's not a clever responsive, it doesn't address anything said, and it is rude. 

 ^

 

bruh switch to dark mode its at the bottom of this page

VPN Server Guide

Link to comment
Share on other sites

Link to post
Share on other sites

21 minutes ago, RockSolid1106 said:

I went through your code on the repl and it seems to be working?

 

Website URL hidden because it was previously moderated.

  Reveal hidden contents

On my iPhone:

 

DDFDBAC0-E39A-43DB-BC24-F7C14E815488.jpeg.96d7ba1b57b80ae36157394da50835d4.jpeg

 

Desktop:

image.thumb.png.88dd0198e495efb28ce758465f99f2e3.png

 

Huh. Well it may be the size of my screen, but thanks for clarifying!

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, TheCoder2019 said:

Huh. Well it may be the size of my screen, but thanks for clarifying!

On a little side note, iPads are considered as a Macintosh for some reason.


Here’s the output if you print the variable “user_agent”:

Spoiler

33487697-A080-4620-A61D-3B8B30024FB2.jpeg.94f74c18223f5daf552bfb5241b222ab.jpeg


Might want to check that if you’re testing that from your iPad.

Edited by RockSolid1106
On 4/5/2024 at 10:13 PM, LAwLz said:

I am getting pretty fucking sick and tired of the "watch something else" responses. It's such a cop out answer because you could say that about basically anything, and it doesn't address the actual complaints. People use it as some kind of card they pull when they can't actually respond to the criticism raised but they still feel like they need to defend some company/person. If you don't like this thread then stop reading it. See how stupid it is? It's basically like telling someone "shut the fuck up". It's not a clever responsive, it doesn't address anything said, and it is rude. 

 ^

 

bruh switch to dark mode its at the bottom of this page

VPN Server Guide

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, RockSolid1106 said:

user_agent

how? shell? cuz it aint workin

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, TheCoder2019 said:

how? shell? cuz it aint workin

umm just add print(user_agent)? And it will print that out on the console

Spoiler

image.png.59772a7e417ccfe06b082ff0a980bba6.png

 

Edited by RockSolid1106
On 4/5/2024 at 10:13 PM, LAwLz said:

I am getting pretty fucking sick and tired of the "watch something else" responses. It's such a cop out answer because you could say that about basically anything, and it doesn't address the actual complaints. People use it as some kind of card they pull when they can't actually respond to the criticism raised but they still feel like they need to defend some company/person. If you don't like this thread then stop reading it. See how stupid it is? It's basically like telling someone "shut the fuck up". It's not a clever responsive, it doesn't address anything said, and it is rude. 

 ^

 

bruh switch to dark mode its at the bottom of this page

VPN Server Guide

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×