#!/usr/bin/env python # -*- coding: utf-8 -*- """ Web server plugin Tested with scribus 1.5.0 Author: William Bader 11Aug14 wb initial version """ # import utility packages import sys # check that the script is running from inside scribus try: from scribus import * except ImportError: print "This script only runs from within Scribus." sys.exit(1) # import web server modules from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer PORT_NUMBER = 8080 # Handle incoming requests from the browser class myHandler(BaseHTTPRequestHandler): # Handler for the GET requests def do_GET(self): self.send_response(200) self.send_header('Content-type','text/html') self.end_headers() # Send the html message self.wfile.write("Hello World !") return def main(): try: # Create a web server and define the handler to manage the incoming request server = HTTPServer(('', PORT_NUMBER), myHandler) print 'Started httpserver on port ' , PORT_NUMBER # Wait forever for incoming http requests server.serve_forever() except KeyboardInterrupt: print '^C received, shutting down the web server' server.socket.close() # start the script if __name__ == '__main__': messageBox("Server", "Starting Web Server at http://localhost:8080/", ICON_INFORMATION) main()