39 lines
887 B
Python
39 lines
887 B
Python
from flask import Flask, request
|
|
from flask_restful import Resource, Api
|
|
import utils
|
|
import json
|
|
|
|
app = Flask(__name__)
|
|
api = Api(app)
|
|
|
|
|
|
class Domain():
|
|
def __init__(self, domain):
|
|
self.whois = utils.whoisData.WhoIS(domain).__dict__
|
|
self.dns = utils.dns.DNS(domain).__dict__
|
|
|
|
|
|
class DNSLookup(Resource):
|
|
def get(self, domain=None):
|
|
auth = request.headers.get('X-AUTH')
|
|
if auth != None:
|
|
return [{'message': 'Please auth'}, 'error']
|
|
if domain == None:
|
|
return [{'message': 'Please specify a domain name'}, 'error']
|
|
else:
|
|
ret = Domain(domain)
|
|
status = 'success'
|
|
return [ret.__dict__, status]
|
|
|
|
|
|
api.add_resource(DNSLookup, '/lookup', '/lookup/<string:domain>')
|
|
|
|
|
|
@app.route('/')
|
|
def index():
|
|
return ''
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app.run(debug=True, host='0.0.0.0')
|