Skip to content

Commit

Permalink
If we cannot guess the type of local file, fallback to JSON
Browse files Browse the repository at this point in the history
This is an experimental feature that may need to be reverted
but it seems like it may be a useful hack.

In the past if the type could not be guessed we'd get an
error from the wsgi server. Now, intsead, fallback to application/json.

This makes it possible to drop JSON data files in the assets dir
for local testing. This can be useful when you want to load a tiddler
from local instead of remote. Usually we wouldn't expect these
files to get pushed. In fact the only way I've used it so far
is in a tsapp that _never_ gets pushed.
  • Loading branch information
cdent committed Jun 15, 2013
1 parent a59110c commit da08773
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tsapp/__init__.py
Expand Up @@ -10,7 +10,7 @@
import sys


__version__ = '0.6.1'
__version__ = '0.7.0'


def error_exit(code, message=""):
Expand Down
3 changes: 3 additions & 0 deletions tsapp/proxy.py
Expand Up @@ -242,6 +242,9 @@ def handle_get(environ, start_response, config):
local_path = path_parts[-1]
filehandle = in_assets(local_path)
mime_type = mimetypes.guess_type(local_path)[0]
# Fall back to JSON if we cannot guess
if not mime_type:
mime_type = 'application/json'
else:
raise IOError('path wrong length')
status = '200 OK'
Expand Down

0 comments on commit da08773

Please sign in to comment.