Scan the QR code below with the PlexPy Android app to automatically register it with the server.
+ Make sure the PlexPy Address below is correct.
+ 127.0.0.1 and localhost will not work.
-
-
+
+
+
Note: This is a private IP address. PlexPy will not be reachable outside of your home network.
Access PlexPy externally to generate the QR code for remote access.
@@ -2034,14 +2037,16 @@ $(document).ready(function() {
parser.href = url;
isPrivateIP(parser.hostname).then(function (valid) {
$('#api_qr_private').toggle((valid !== 'n/a'));
+ }, function () {
+ $('#api_qr_private').toggle(false);
});
$('#api_qr_https').toggle(!(url.startsWith('https')));
$.get('generate_api_key', { device: true }).then(function (token) {
- var encoded_string = url + '|' + token;
- $('#api_qr_string').html(encoded_string);
+ $('#api_qr_address').val(url);
+ $('#api_qr_token').val(token);
$('#api_qr_code').empty().qrcode({
- text: encoded_string
+ text: url + '|' + token
});
(function poll(){
@@ -2072,6 +2077,22 @@ $(document).ready(function() {
});
});
+ $('#api_qr_address').change(function () {
+ var url = $(this).val();
+ var parser = document.createElement('a');
+ parser.href = url;
+ isPrivateIP(parser.hostname).then(function (valid) {
+ $('#api_qr_private').toggle((valid !== 'n/a'));
+ }, function () {
+ $('#api_qr_private').toggle(false);
+ });
+ $('#api_qr_https').toggle(!(url.startsWith('https')));
+
+ $('#api_qr_code').empty().qrcode({
+ text: url + '|' + $('#api_qr_token').val()
+ });
+ });
+
$('#api-qr-modal').on('hidden.bs.modal', function () {
if (!(verifiedDevice)) {
$.ajax({
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index a892a8d7..743502c5 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -4775,9 +4775,18 @@ class WebInterface(object):
else:
scheme = 'http'
+ # Have to return some hostname if socket fails even if 127.0.0.1 won't work
+ hostname = '127.0.0.1'
+
if plexpy.CONFIG.HTTP_HOST == '0.0.0.0':
import socket
- hostname = socket.gethostbyname(socket.gethostname())
+ try:
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
+ s.connect(('', 0))
+ hostname = s.getsockname()[0]
+ except socket.error:
+ hostname = socket.gethostbyname(socket.gethostname())
else:
hostname = plexpy.CONFIG.HTTP_HOST