用python做ppt服务用于导入图片
import SocketServerimport win32com.client
import sys
class MyTCPHandler(SocketServer.BaseRequestHandler):
"""
The RequestHandler class for our server.
It is instantiated once per connection to the server, and must
override the handle() method to implement communication to the
client.
"""
def handle(self):
# self.request is the TCP socket connected to the client
self.data = self.request.recv(1024).strip()
# print "{} wrote:".format(self.client_address)
# print self.data
# just send back the same data, but upper-cased
# self.request.sendall(self.data.upper())
Application = win32com.client.Dispatch("PowerPoint.Application")
currentSlide = Application.ActiveWindow.View.Slide
currentSlide.Shapes.Paste()
HOST, PORT = "localhost", int(sys.argv)
#HOST, PORT = "localhost", 9999
# Create the server, binding to localhost on port 9999
server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler)
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
server.serve_forever()
页:
[1]