PORT 8080 / IP 0000, Need Help

python

#1

I am new to Python and Cloud9 and I am trying to run my script but I keep getting the following message:

Your code is running at https://teacher-stats-mundo1.c9users.io.
Important: use os.getenv(PORT, 8080) as the port and os.getenv(IP, 0.0.0.0) as the host in your scripts!

How do I resolve this?

Thank you!


#2

Reading another post in the community, I placed the following two lines in the beginning of my “py” file:

os.getenv(‘PORT’, ‘8080’)
os.getenv(‘IP’, ‘0.0.0.0’)

Now I get the following message when I press “Run”:

Traceback (most recent call last):
File “/home/ubuntu/workspace/teacher_stats.py”, line 1, in
os.getenv(‘PORT’, ‘8080’)
NameError: name ‘os’ is not defined

I even tried ‘import os’ above those two lines and it returns the original message. Any suggestions?


#3

(Disclaimer: Not an expert, just another user)

If your script needs to know its own host address and port then os.getenv() would be the way to find out. But if it doesn’t, and there are many scripts that don’t need the information, then you don’t need to bother.

That “important” message is essentially just a warning or information - it’s not an error message that says you’re doing something wrong. I personally just ignore it.