Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

myapp.wsgi: Handle requests for .json files #1

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

jwodder
Copy link
Member

@jwodder jwodder commented Feb 6, 2024

This should fix the 404 reported at dandi/dandidav#43 (comment).

Also, my editor plugins automatically reformatted the code.

response = 'Directory not found.'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(response)))]
status = "404 Not Found"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what actually changed in this file besides formatting? would have been nice to have two separate commits at least or some human description of the change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is new:

if os.path.isfile(full_path) and os.path.splitext(full_path)[1] == ".json":
status = "200 OK"
response_headers = [
("Content-type", "application/json"),
("Content-Length", str(os.path.getsize(full_path))),
]
start_response(status, response_headers)
with open(full_path, "rb") as fp:
return iter(lambda: fp.read(65535), b"")

]
start_response(status, response_headers)
with open(full_path, "rb") as fp:
return iter(lambda: fp.read(65535), b"")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, this is the change -- pass .json files content as is.... will merge/"deploy"

@yarikoptic yarikoptic merged commit 6ad531a into dandi:master Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants