如何在ubuntu中设置nodejs应用程序服务器

时间:2015-09-15 14:22:29

标签: node.js ubuntu

我不明白为什么我有这个问题,我在第二部分显示输出。在遵循教程“如何在Ubuntu 14.04上设置Node.js应用程序生产”的同时,我做了所有事情。

我创建了一个脚本来测试我的私人IP地址,就像这样

from Tkinter import *

master = Tk()
master.geometry('800x480+0+0')
master.title('Gateway Logger')

names = ['Annette', 'Heather', 'Tracey', 'Amy', 'Josh', 'Chris'
         , 'Lekh', 'Ellie', 'Sarah', 'Richard', 'Paula', 'Michelle'
         , 'Martin', 'Dave', 'Phil']
visitors = ['Visitor 1', 'Visitor2', 'Visitor 3', 'Visitor 4', 'Visitor 5', 'Visitor 6']

name_width = 20
name_height = 5
xpad = 5
ypad = 5
col = 0
roww = 0

sarah='out'

def clock_mast(n):
    iowid=40
    iohi=15
    global clock
    print "This is: " +str(n)
    clock = Toplevel(width=300, height =300)
    clock.title('Clock In/Out')

    staff_name = Label (clock, text = n, font = "Verdana 24")
    staff_name.grid(row=1,column=1,columnspan=2)

    inbut=Button(clock, width=iowid, height=iohi, text='Clock In', bg='green',command=lambda n=n:clock_in(n))
    inbut.grid(row=2, column=1, padx=10,pady=50, columnspan=1)
    outbut=Button(clock, width=iowid, height=iohi, text='Clock Out', bg='red',command=lambda n=n:clock_out(n))
    outbut.grid(row=2, column=2, padx=10,pady=50, columnspan=1)



def clock_in(n):
    global clock
    global button_dict             #This is not really necessary, but I put it there to be explicit.
    button_dict[n].configure(bg='green')     #Choose whatever properties you want to choose to configure
    clock.destroy()

def clock_out(n):
    global clock
    global button_dict             #This is not really necessary, but I put it there to be explicit.
    button_dict[n].configure(bg='red')     #Choose whatever properties you want to choose to configure
    clock.destroy()

button_dict = {}

for n in names:  
    button_dict[n] = Button(master,text=n,width = name_width, height = name_height,command=lambda n=n: clock_mast(n))
    button_dict[n].grid(row = roww, column = col,padx = xpad, pady = ypad)
    col += 1
    if col == 3:
        col = 0
        roww += 1



master.mainloop()

我在测试应用程序时遇到的问题。

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(8080, 'myPrivateIp');
console.log('Server running at http://myPrivateIp:8080/');

1 个答案:

答案 0 :(得分:1)

listen的第二个参数不是域名,是要侦听的地址。它可能类似于192.168.x.x127.0.0.10.0.0.0(表示所有地址。)。默认值为127.0.0.1

这意味着你应该删除listen的第二个参数。

相关问题