jeudi 2 août 2018

web service with python to reslove ip addresses

I'm new to python and I need urgently to create a web service in python. I need a text file as input that contains all host-names to resolve. I already made this script:

import flask 
from flask import request, jsonify, Api, Resource, reqparse
import socket
app = flask.Flask(__name__)
api=Api(app)
app.config["DEBUG"] = True
@app.route('/hostName', methods=['POST'])
def ipAdd():
hostName    = "www.youtube.com"
ipAddress   = socket.gethostbyname_ex(hostName)
print("IP addresses of the host name {}: {}".format(hostName, ipAddress))
return jsonify(ipAddress)

any idea please?

Aucun commentaire:

Enregistrer un commentaire