In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces python how to create a web service, the article is very detailed, has a certain reference value, interested friends must read it!
Create a disposable, fast, small web service
Sometimes we need to do some simple, basic RPC-like interaction between two machines or services. We want to use the B program to call a method in the A program in a simple way-sometimes on another machine. For internal use only.
I do not encourage the use of the methods described here in non-internal, one-off programming. We can use a protocol called XML-RPC (corresponding to this Python library) to do this.
Here is an example of using the SimpleXMLRPCServer module to build a fast, small file reading server:
From SimpleXMLRPCServer import SimpleXMLRPCServer def file_reader (file_name): with open (file_name, r) as f: return f.read () server = SimpleXMLRPCServer ((localhost, 8000)) server.register_introspection_functions () server.register_function (file_reader) server.serve_forever ()
Client
Import xmlrpclibproxy = xmlrpclib.ServerProxy (http://localhost:8000/) proxy.file_reader (/ tmp/secret.txt)
This gives us a remote file reading tool with no external dependencies and only a few lines of code (of course, there are no security measures, so you can only do this at home).
The above is all the content of the article "how to create a web service for python". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow 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.