4

I have managed to to install flask and run the hello-world script:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()

I was impressed how easy it was. Then I wanted to make my web-server visible externally. As recommended, I put host='0.0.0.0' as the argument of run function. Then I found my IP address (in Google) and put it in the address line of my web browser (while the hello-world-script was running).

As a result I got: "A username and password are being requested" and a dialogue box where I need to put a user name and password. I am not sure but I think it comes from my wireless network. Is there a way to change this behaviour?

inf3rno
  • 24,976
  • 11
  • 115
  • 197
Roman
  • 124,451
  • 167
  • 349
  • 456
  • BTW, -1 for the idea of making a *development server* available externally. Get a serious server (Nginx/Apache/Gunicorn) or use a PAAS (OpenShift/AppFog/...). – gioi Mar 07 '13 at 16:44

2 Answers2

7

How are you trying to run your application? If you run flask as app.run() - flask creates its own WSGI server on your host (by default 127.0.0.1) and port (by default 5000) (need permissions if port < 1000). If you run flask using nginx + WSGI or etc. your server resolves host and port.

Now it looks like you want get application by port which resolved your server like nginx or Apache. Try to get flask application by http://your-server-host-or-ip:5000 with the default port or try to change the port (set explicit) like app.run('0.0.0.0', 8080) and get it by http://your-server-host-or-ip:8080.

By the way, you can always get IP address using command-line tools e.g. ifconfig for Unix-like systems, or ipconfig /all for Windows.

mechanical_meat
  • 163,903
  • 24
  • 228
  • 223
tbicr
  • 24,790
  • 12
  • 81
  • 106
  • Then the response "A username and password are being requested" is not from his server. However he can't get access to server behind NAT. – tbicr Mar 04 '13 at 07:45
1

To elaborate a little bit onto what @tbicr said, that password prompt indicates that you're trying to connect to your IP on port 80, which is most likely hosting an administration page for your router/modem. You want to connect to your IP on port 5000, the default port for Flask apps run with app.run().

Anorov
  • 1,990
  • 13
  • 19