简体   繁体   中英

Why Flask gives 404 for files in the same directory with my application

Let's say I have a domain. Under home directory of the domain I have a text(.txt) file called note.txt. Like below

https://www.example.com/note.txt

When I access the url, browser display text string contained inside the file. But when I run a Flask under that domain instead of a traditional html,css,javascript,php app, server return 404 error even though the file exists in fact at the same location. I can see this from the ftp client.

So why does the server returns 404 error when the site hosts a python app instead of the more traditional html,css,javascript,php app?

What you are missing here is that Flask has its own URL routing .

The answer for "why does the server returns 404 error" is that URL routing should be explicit (nothing happens unless you tell it to happen) instead of implicit (everything on the server is exposed by default). Because PHP chose the latter approach, WordPress, Drupal, et. al. traditional PHP sites are getting hacked very easily when they are given to people who don't have the full picture what they are doing. It might be convenient in the beginning, but it is also an open invitation for script kiddies to raid your server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM