In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how nginx returns json or text format", the content is simple and easy to understand, organized clearly, I hope to help you solve doubts, let Xiaobian lead you to study and learn "how nginx returns json or text format" this article bar.
1. Return to text format
location ~ ^/get_text { default_type text/html; return 200 'hello world! '; }
Return to JSON format
location ~ ^/get_json { default_type application/json; return 200 '{"status":"success","result":"hello world! "}'; }
3. You can also simply return different strings according to the requested URL.
location ~ ^/get_text/article/(.*)_ (\d+).html$ { default_type text/html; set $s $1; set $d $2; return 200 str:$s$d; }
4. The returned character set setting, the default is to return with GBK character set
location ~ ^/get_text { default_type text/html; add_header Content-Type 'text/html; charset=utf-8'; return 200 'Hello, World! '; }
Note: default_type must be added, otherwise the browser will download it as an unrecognized file
The above is "how nginx returns json or text format" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.