Created
September 5, 2014 12:23
-
-
Save untitaker/53d34b624910d19da92f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flask | |
app = flask.Flask('testapp') | |
@app.route('/dir') | |
def from_dir(): | |
return flask.send_from_directory('data', 'file.txt') | |
@app.route('/file') | |
def from_file(): | |
return flask.send_file('data/file.txt') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
testapp | |
data | |
file.txt | |
__init__.py | |
runserver.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from testapp import app | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, I check the example, and I am pretty sure the http://127.0.0.1/dir will occur a 404 not found error in my computer. here is the error code: "if not os.path.isfile(filename):" in send_from_directory.
mac osx, Python 2.7.5 :: Anaconda 1.8.0 (x86_64).