john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

http server javascript button onclick show alert

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python
import time
import BaseHTTPServer
from pprint import pprint
import urlparse

HOST_NAME = 'localhost'
PORT_NUMBER = 8080


class MyHandler( BaseHTTPServer.BaseHTTPRequestHandler ):


    def send_headers( self , content_type ):
        self.send_response( 200 )
        self.send_header( 'Content-type' , content_type )
        # self.send_header( "Content-length" , len( RESPONSE ) )
        self.end_headers()


    def do_GET( self ):
    """
        javascript_alert = '<script type="text/javascript">'
        javascript_alert = javascript_alert + 'function show_alert() { alert("JavaScript alert!"); } </script>'
        button = '<input type="button" onclick="show_alert()" value="Show alert box" />'
    content = '<html><body>' + javascript_alert + ' hi ' + button + '</body></html>'
    """

    button = '<input type="submit" onclick="return confirm(\'Are you sure?\');" value="Confirmation" name="confirmation" id="confirmation">'
    content = '<html><body>' ' hi ' + button + '</body></html>'


        self.send_headers( 'text/html' )
        self.wfile.write( '%s' % ( content ) )
        pprint( vars( self ) )




if __name__ == '__main__':
    server_class = BaseHTTPServer.HTTPServer
    httpd = server_class( ( HOST_NAME , PORT_NUMBER ), MyHandler )
    print time.asctime(), "Server Starts - %s:%s" % ( HOST_NAME , PORT_NUMBER )
    try:
            httpd.serve_forever()
    except KeyboardInterrupt:
            pass
    httpd.server_close()
    print time.asctime(), "Server Stops - %s:%s" % ( HOST_NAME , PORT_NUMBER )

  • « phantomjs javascript test
  • Openssl certificate generation signing »

Published

Oct 10, 2013

Category

python

~160 words

Tags

  • alert 1
  • button 10
  • http 12
  • javascript 43
  • onclick 2
  • python 180
  • server 66
  • show 2