alyferryhalo
alyferryhalo

Reputation: 43

Framework Bottle and OSError

I am trying to make a very simple thing with Bottle. I would like to take my .json file and convert it to the HTML table.

There are my files:

main.py

from bottle import route, run, template, error

HOST = '192.168.47.101'

with open('data.json', 'r') as file:
    data = file.read()

@route('/main_page')
def serve_homepage():
    return template('disp_table', rows = data)

@error(404)
def error404(error):
    return 'There is nothing... :('

run(host=HOST, port=8080) 

disp_table.tpl

%# disp_table.tpl
<table border="1">
<tr>
%for row in rows:
<th>{{row}}</th>
%end
</table>

data.json

{
'First row' : [1,2,3,4,5,6,7,8,9],
'Second row': [10,11,12,13,14,15,16,17,18,19]
} 

I suspect to see something like this:

---------------------------------------------
|First row  | 1,2,3,4,5,6,7,8,9             |
---------------------------------------------
|Second row | 10,11,12,13,14,15,16,17,18,19 |
---------------------------------------------

But I have this error after command python3 main.py:

OSError: [Errno 99] Cannot assign requested address

I use this:

What is wrong with my code? How can I fix it?

Upvotes: 0

Views: 42

Answers (1)

ron rothman
ron rothman

Reputation: 18128

The error means that your server process couldn't bind to the port that you specified (8080). You can either (1) try a different port, e.g.

run(host=HOST, port=8580)

or (2) find out which process is already using port 8080 and shut that down.

Upvotes: 1

Related Questions