Sometimes, we want to set content type with Python Flask.
In this article, we’ll look at how to set content type with Python Flask.
How to set content type with Python Flask?
To set content type with Python Flask, we can use the Response
class.
For instance, we write
from flask import Response
@app.route("/ajax_ddl")
def ajax_ddl():
xml = "foo"
return Response(xml, mimetype="text/xml")
to create a Response
object with the xml
string as the body and the mimetype
set to the MIME type of the response.
Conclusion
To set content type with Python Flask, we can use the Response
class.
Popular Posts
- Show / Hide div based on dropdown selected using jQuery
- Infinite Scrolling on PHP website using jQuery and Ajax with example
- How to Convert MySQL Data to JSON using PHP
- Custom Authentication Login And Registration Using Laravel 8
- Slick Slider Basic With Example
- Autosuggestion Select Box using HTML5 Datalist, PHP and MySQL with Example
- How to change date format in PHP?
- php in_array check for multiple values
- Adaptive Height In Slick Slider
- JavaScript Multiple File Upload Progress Bar Using Ajax With PHP
- Slick Slider Center Mode With Example
- How to Scroll to an Element with Vue 3 and ?
- Image Lazy loading Using Slick Slider
- Calculate Subtotal On Quantity Increment in Woocommerce Single Product Page
- Slick Slider Multiple Items With Example
Total Views: 259
Share