RaySl
RaySl

Reputation: 497

What mime-type should I return for a python string

I have a web API that returns python dictionaries or lists as a response that I eval() in python scripts that use the API, for completness I wanted to set a proper content-type but not sure what would be best to use "text/x-python" or maybe "application/python", or something else?

[edit] I'm also outputting JSON, I'm doing Python as an option mainly for internal use.[/edit]

Upvotes: 3

Views: 3944

Answers (2)

bortzmeyer
bortzmeyer

Reputation: 35459

The authoritative registry is at IANA and, no, there is no standard subtype for Python. So, do not use type like "application/python" but you may use private subtypes such as "text/x-python" (the one I find in the mime-support package on my Debian).

Upvotes: 3

Ned Batchelder
Ned Batchelder

Reputation: 375594

I doubt there's an established MIME type. Have you considered using JSON instead, it is almost the same as a Python dict, and has a better established culture of tools and techniques.

Upvotes: 8

Related Questions