viernes, agosto 10, 2012

Whois app in Bottle

A very small and very simple web application that shows a whois query :)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
from bottle import get, post, request, run
import subprocess

@get('/whois')
def whois_form():

    return '''<form method="POST">
              Nombre de dominio: <input name="domain" type="text">
              </form>
              '''

@post('/whois')
def whois_submit():
    domain_name = request.forms.get('domain')
    query = subprocess.Popen('whois'+' '+domain_name, shell=True, stdout=subprocess.PIPE).communicate()[0]
    return "<p> %s <p>" % query

run(host='localhost', port=8000)