Commits

Ivan Vučica  committed 51b3676

Preparing for an IPP server in Python

  • Participants
  • Parent commits 9b93021

Comments (0)

Files changed (2)

File advertiseairprint.m

 // for more details, see:
 // see http://www.jrwz.net/technical/mDNS-AirPrint/s06.html
 
+#if EMBEDDED_SERVER
 int port = 0;
+#else
+int port = 59000;
+#endif
 
 // advertiseService() could probably be implemented with "dns-sd" in command-line
 void advertiseService()
 
 int main(int argc, char** argv)
 {
+#if EMBEDDED_SERVER
 	streamDelegate = [StreamDelegate new];
 	createService();
+#endif
 	advertiseService();
 #if !USE_APPKIT
 	[[NSRunLoop currentRunLoop] run];
+#!/usr/bin/env python2.7
+import BaseHTTPServer
+
+class IPPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+	def do_HEAD(s):
+		s.send_response(200)
+		s.send_header("Content-type", "text/html")
+		s.end_headers()
+	def do_GET(s):
+		s.send_response(400)
+		s.send_header("Content-type", "text/html")
+		s.end_headers()
+		s.wfile.write("<html><head><title>No GET</title></head>");
+		s.wfile.write("<body><p>GET is not supported at %s</p></body></html>" % s.path);
+	def do_POST(s):
+		print dir(s)
+		print s.headers
+		print s.rfile
+		print dir(s.rfile)
+		s.send_response(400)
+		s.send_header("Content-type", "text/html")
+		s.end_headers()
+		s.wfile.write("<html><head><title>No POST</title></head>");
+		s.wfile.write("<body><p>POST is not supported at %s</p></body></html>" % s.path);
+		
+class IPPServer(BaseHTTPServer.HTTPServer):
+	pass
+
+def main():
+	server_address = ('', 59000)
+	httpd = IPPServer(server_address, IPPHandler)
+	httpd.serve_forever()
+	# while 1: httpd.handle_request()
+main()