fix mobile redirect
This commit is contained in:
@ -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_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('--root_url', type=str, default=None, help='Root URL for the Panel app (optional)')
|
||||
return parser.parse_args()
|
||||
|
||||
def panel_main():
|
||||
args = parse_args()
|
||||
hipsterfy = Hipsterfy(args.spotify_client_id, args.spotify_client_secret)
|
||||
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")
|
||||
pn.serve(
|
||||
|
@ -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
|
||||
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
|
||||
def player_qr_html():
|
||||
# pn.state.location.href ist erst nach dem ersten Request gesetzt
|
||||
base_url = pn.state.location.href or main_url
|
||||
# Basis-URL ohne evtl. Pfad/Query
|
||||
from urllib.parse import urlparse
|
||||
parsed = urlparse(base_url)
|
||||
base = f"{parsed.scheme}://{parsed.netloc}"
|
||||
if root_url is None:
|
||||
base_url = pn.state.location.href
|
||||
# Basis-URL ohne evtl. Pfad/Query
|
||||
from urllib.parse import urlparse
|
||||
parsed = urlparse(base_url)
|
||||
base = f"{parsed.scheme}://{parsed.netloc}"
|
||||
else:
|
||||
base = root_url
|
||||
url = base + "/qr/scan.html"
|
||||
return generate_qr_code_base64(url)
|
||||
|
||||
|
Reference in New Issue
Block a user