Created
July 21, 2014 19:54
-
-
Save clsource/d4af2da5926655ce32fc to your computer and use it in GitHub Desktop.
Simple Presentation Server Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table style="font-size:110px;padding:10px;margin:10px;margin-top:50px;"> | |
<tr> | |
<th></th> | |
<th><a href="/up">UP</a></th> | |
<th></th> | |
</tr> | |
<tr> | |
<td><a href="/left">LEFT</a></td> | |
<td></td> | |
<td><a href="/right">RIGHT</a></td> | |
</tr> | |
<tr> | |
<td></td> | |
<td><a href="/down">DOWN</a></td> | |
<td></td> | |
</tr> | |
<tr><td style="padding:100px"></td><td></td><td></td></tr> | |
<tr> | |
<td></td> | |
<td><a href="/space">SPACE</a></td> | |
<td></td> | |
</tr> | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Simple Servidor de Datos | |
# Crea un servidor web para | |
# controlar la presentacion desde el iPhone | |
# @author Camilo Castro | |
# @date 17/07/2014 | |
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer | |
from os import curdir,sep | |
import win32api | |
import win32com.client | |
class MyHandler(BaseHTTPRequestHandler): | |
def do_GET(self): | |
shell = win32com.client.Dispatch("WScript.Shell") | |
try: | |
# Enviamos el comando de teclado segun url | |
if(self.path.endswith('/up')): | |
print "Sending Up" | |
shell.SendKeys("{UP}") | |
if(self.path.endswith('/down')): | |
print "Sending Down" | |
shell.SendKeys("{DOWN}") | |
if(self.path.endswith('/left')): | |
print "Sending Left" | |
shell.SendKeys("{LEFT}") | |
if(self.path.endswith('/right')): | |
print "Sending Right" | |
shell.SendKeys("{RIGHT}") | |
if(self.path.endswith('/space')): | |
print "Sending Space" | |
shell.SendKeys(" ") | |
# Mostramos el html del teclado | |
self.send_response(200) | |
self.send_header('Content-type','text/html') | |
self.end_headers() | |
html = open(curdir + sep + 'keys.html') | |
self.wfile.write(html.read()) | |
html.close() | |
except IOError: | |
self.send_error('404','404 Not Found') | |
def do_POST(self): | |
pass | |
def main(): | |
serverPort = 8080 | |
try: | |
server = HTTPServer(('',serverPort),MyHandler) | |
print 'Comenzando a servir los datos localhost:{}'.format(serverPort) | |
server.serve_forever() | |
except KeyboardInterrupt: | |
print 'Apagando servidor' | |
server.socket.close() | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment