Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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]

like image 346
RaySl Avatar asked Jun 25 '26 17:06

RaySl


2 Answers

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.

like image 83
Ned Batchelder Avatar answered Jun 28 '26 06:06

Ned Batchelder


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

like image 22
bortzmeyer Avatar answered Jun 28 '26 08:06

bortzmeyer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!