fix mobile redirect

This commit is contained in:
2025-08-04 17:24:39 +02:00
parent deb43a47f7
commit 7c24d9a7c5
3 changed files with 12 additions and 8 deletions

View File

@ -11,13 +11,14 @@ def parse_args():
parser.add_argument('--spotify_client_id', type=str, required=True, help='Spotify Client ID') parser.add_argument('--spotify_client_id', type=str, required=True, help='Spotify Client ID')
parser.add_argument('--spotify_client_secret', type=str, required=True, help='Spotify Client Secret') parser.add_argument('--spotify_client_secret', type=str, required=True, help='Spotify Client Secret')
parser.add_argument('--port', type=int, default=5006, help='Port to run the Panel app on') parser.add_argument('--port', type=int, default=5006, help='Port to run the Panel app on')
parser.add_argument('--root_url', type=str, default=None, help='Root URL for the Panel app (optional)')
return parser.parse_args() return parser.parse_args()
def panel_main(): def panel_main():
args = parse_args() args = parse_args()
hipsterfy = Hipsterfy(args.spotify_client_id, args.spotify_client_secret) hipsterfy = Hipsterfy(args.spotify_client_id, args.spotify_client_secret)
playlist_uri = 'https://open.spotify.com/playlist/5grJs3PKyLE0cL5NYmkGIF' playlist_uri = 'https://open.spotify.com/playlist/5grJs3PKyLE0cL5NYmkGIF'
app = lambda: create_panel_page(hipsterfy, playlist_uri) app = lambda: create_panel_page(hipsterfy, playlist_uri, args.root_url)
static_dir = os.path.join(os.path.dirname(__file__), "static") static_dir = os.path.join(os.path.dirname(__file__), "static")
pn.serve( pn.serve(

View File

@ -9,7 +9,7 @@ pn.extension("filedownload", "notifications", "location")
def create_panel_page(hipsterfy: Hipsterfy, playlist_uri: str=None) -> pn.Template: def create_panel_page(hipsterfy: Hipsterfy, playlist_uri: str=None, root_url = None) -> pn.Template:
# create widgets # create widgets
playlist_uri = pn.widgets.TextInput(name='Playlist URI', value=playlist_uri or '', placeholder='Enter Spotify Playlist URI') playlist_uri = pn.widgets.TextInput(name='Playlist URI', value=playlist_uri or '', placeholder='Enter Spotify Playlist URI')
@ -182,11 +182,14 @@ def create_panel_page(hipsterfy: Hipsterfy, playlist_uri: str=None) -> pn.Templa
# Dynamisch: QR-Code aktualisiert sich, wenn die Seite unter einer anderen URL läuft # Dynamisch: QR-Code aktualisiert sich, wenn die Seite unter einer anderen URL läuft
def player_qr_html(): def player_qr_html():
# pn.state.location.href ist erst nach dem ersten Request gesetzt # pn.state.location.href ist erst nach dem ersten Request gesetzt
base_url = pn.state.location.href or main_url if root_url is None:
base_url = pn.state.location.href
# Basis-URL ohne evtl. Pfad/Query # Basis-URL ohne evtl. Pfad/Query
from urllib.parse import urlparse from urllib.parse import urlparse
parsed = urlparse(base_url) parsed = urlparse(base_url)
base = f"{parsed.scheme}://{parsed.netloc}" base = f"{parsed.scheme}://{parsed.netloc}"
else:
base = root_url
url = base + "/qr/scan.html" url = base + "/qr/scan.html"
return generate_qr_code_base64(url) return generate_qr_code_base64(url)

View File

@ -1,6 +1,6 @@
[project] [project]
name = "hipsterfy" name = "hipsterfy"
version = "0.2.3" version = "0.3.2"
description = "" description = ""
authors = [ authors = [
{name="Jonas Weinz"} {name="Jonas Weinz"}