Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS X web sharing and Django

Tags:

macos

django

I created a web app with Django and I have it running on localhost (http://127.0.0.1:8000/), my question is, how can I make it available to the world, using Mac OS X's web sharing or something?

Thanks!

like image 862
pns Avatar asked Dec 06 '22 04:12

pns


2 Answers

While you start the server specify the public ip or for any ip use 0.0.0.0

Example:

sudo python manage.py runserver 0.0.0.0:80

If you start your application without ip and port its bind only for loopback which is 127.0.0.1 and will not accessible in your network.

like image 137
piyer Avatar answered Dec 23 '22 08:12

piyer


First off, I would strongly suggest you not to serve a website from your Mac. It's a really bad idea™. Both Mac OS X web sharing and Django's included http server (which I assume you're using) are intended for testing purposes only, for a number of reasons concerning speed, security et al. which is frankly too long to post here (but I hope that someone will :)

Second, it's already open to the world: anyone can connect to your computer using your IP address instead of the loopback 127.0.0.1 (unless you're NATted). This, again, is quite useful to test it (and have your friends/colleagues/boss) test it temporarily, but again is not fit for production use. Really.

like image 23
Agos Avatar answered Dec 23 '22 08:12

Agos