initial working version
This commit is contained in:
45
service.py
Normal file
45
service.py
Normal file
@ -0,0 +1,45 @@
|
||||
import os
|
||||
|
||||
from eppy.client import EppClient
|
||||
from eppy.doc import *
|
||||
from flask import Flask
|
||||
from flask_restful import Resource, Api
|
||||
|
||||
|
||||
extra_ext_uris = [
|
||||
'http://www.sk-nic.sk/xml/epp/sk-contact-ident-0.2',
|
||||
'urn:ietf:params:xml:ns:rgp-1.0',
|
||||
'urn:ietf:params:xml:ns:auxcontact-0.1'
|
||||
]
|
||||
|
||||
|
||||
extra_nsmap = {
|
||||
'skContactIdent': 'http://www.sk-nic.sk/xml/epp/sk-contact-ident-0.2',
|
||||
'rgp': 'urn:ietf:params:xml:ns:rgp-1.0',
|
||||
'auxcontact': 'urn:ietf:params:xml:ns:auxcontact-0.1'
|
||||
}
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
api = Api(app)
|
||||
|
||||
|
||||
class Domain(Resource):
|
||||
def get(self, domain_name):
|
||||
client = EppClient(ssl_validate_cert=False, ssl_validate_hostname=False)
|
||||
client.connect('epp.sk-nic.sk')
|
||||
|
||||
# client.login('KAFE-0001', '@a3dwK8eyf!B7>0q', extra_ext_uris=extra_ext_uris)
|
||||
client.login(os.environ.get('EPP_NAME'), os.environ.get('EPP_PASSWORD'), extra_ext_uris=extra_ext_uris)
|
||||
|
||||
cmd = EppInfoDomainCommand(extra_nsmap=extra_nsmap)
|
||||
|
||||
cmd.name = domain_name
|
||||
resp = client.send(cmd, extra_nsmap=extra_nsmap)
|
||||
if resp.ok:
|
||||
return {'domain': domain_name, 'exp_date': resp.resData['domain:infData']['exDate']}
|
||||
else:
|
||||
return {'domain': domain_name}, 404
|
||||
|
||||
|
||||
api.add_resource(Domain, '/domain/<string:domain_name>')
|
||||
Reference in New Issue
Block a user