0

Following the complete instructions on this thread, I got my Flask server to work and it is now accessible through different devices, with my config file as follows:

#config.py
DEBUG="True"
UPLOAD_FOLDER="Reports/"
SECRET_KEY = "Supp0s3dT0B3Un1qu3AndS3cr3t"

with app.run() called as

app.run(host = '0.0.0.0', port = 7000, debug = True)

However, setting the SERVER_NAME variable in the config file as

SERVER_NAME = '0.0.0.0'

actually gave me an error and refused to connect as follows:

192.168.0.163 - - [13/May/2016 12:25:58] "GET / HTTP/1.1" 404

However, when I removed it, only then did the server get accessed by my other device. I was accessing my machine through it's IP I found through ifconfig - 192.168.0.126:5000. Any ideas why this happened?

Note: app.run() was called the same way in both the cases.

Community
  • 1
  • 1
Raunaq Kochar
  • 1,024
  • 3
  • 15
  • 24
  • Nowhere in the thread you link someone put an ip in SERVER_NAME, because that's not what you're supposed to do, especially 0.0.0.0. You're supposed to put something like 'myapp' – polku May 13 '16 at 08:43
  • @polku It is mentioned as a solution in the last answer! http://stackoverflow.com/a/35146471/4803814 – Raunaq Kochar May 13 '16 at 09:05
  • Please include an error in your question that you are getting. Paste an image or copy paste all the traceback from console ? – Hassan Mehmood May 13 '16 at 09:09
  • @HassanMehmood Done! It was 192.168.0.163 - - [13/May/2016 12:25:58] "GET / HTTP/1.1" 404 - – Raunaq Kochar May 13 '16 at 09:12
  • Seems like you are giving wrong URL – Hassan Mehmood May 13 '16 at 09:13
  • @HassanMehmood I was accessing it using the IP of my host on the network. 192.168.0.126:5000. And even now, when I try to access it as 192.168.0.126:5000 or 0.0.0.0:5000 it gives me an error. However, when I change SERVER_NAME to 'nhm.dev:5000' and access it with this url, it works. So aren't IP addresses allowed in the SERVER_NAME variable? – Raunaq Kochar May 13 '16 at 09:22
  • Yes, it is possible, I have done this hundreds of time. May be an issue with your machine's settings, firewall or something else that blocking your call. – Hassan Mehmood May 13 '16 at 09:25
  • `SERVER_NAME` is used primarily for supporting subdomains, something that doesn't work with IPs. Do you even need to give it a value? – dirn May 13 '16 at 12:47
  • @dirn I was trying to debug it when I came across this snag. It is not required, but was just wondering why it went wrong. – Raunaq Kochar May 13 '16 at 12:56

0 Answers0