-2

I'm struggling with passing a list from a python file to my bottle server. I have split them up into functions so that when you call it they should be printed.

This what I have so far:

from bottle import route, run, template, request
import sys
sys.path.append("../python")
from connectedDevices import *

@route('/list')
def print_list():
    # Functions taken from connectedDevices
    get_ip()
    get_mac()
    return template('Forum ID: {{get_ip()}})'), get_ip()=forum_id)

run(host='localhost', port=8080)
Alvaromr7
  • 25
  • 8

1 Answers1

0

I managed to solve it, apparently if I use functions from the input file I couldn't call variables independently, only the function lot. I removed them so now I can call the list and used this:

@app.route('/')
def index():
    info={'iplist': iplist, 'maclist': maclist, 'signallist': signallist, 'hostlist': hostlist}
    tpl = '''
    <table>
    %for i in range(len(maclist)):
        IP Address: {{iplist[i]}}
    <br/>
        MAC Address: {{maclist[i]}}
    <br/>
        Signal: {{signallist[i]}}
    <br/>
        Hostname: {{hostlist[i]}}
    <br/>
    <br/>
    %end
    </table>
    '''
    return template(tpl, info)
Alvaromr7
  • 25
  • 8