简体   繁体   中英

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]

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.

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).

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