Jaffer Wilson
Jaffer Wilson

Reputation: 7273

using EVE Python api for request and response

I am trying to use the EVE api with python 3. This is for the first time I am trying to use the API. So what I am trying to do and achieve is given below:
I have a list of name of people. for example:

Adam Gilchrist
Adam Barbar
Adam lobiof
Jaffer Wilson
Janet Wilson
Jane Cold

And many others. I am using the fuzzywuzzy python library. I have loaded these names into an array and using the library function for predicting the approx match of the string from the names using their email address names. For example:
[email protected] is the exampe I have taken. Now, I have written the code for match the string adam.barbar with the name list that I have mentioned above.
I get the approx answers as expected.
Now where is the problem one might think. So here it is:
I want to fetch the response from the API as:

http://127.0.0.1/people/[email protected]

and get the response as the answer of fuzzywuzzy library as json to display on the screen.
I am not using any Database as such and all the names are available in the file format currently. I have search and research about the usage of the EVE API, but could not find the usage as per my requirement. Where ever I searched for the solution I came across MongoDB or any other database. My requirement is database less.
So I want to know in the above mentioned condition, What need to be done if I want to use the Eve API

Upvotes: 1

Views: 774

Answers (1)

Burhan Khalid
Burhan Khalid

Reputation: 174622

I am not using any Database as such and all the names are available in the file format currently.

As you are not using a database, you can use plain flask to solve your problem. It can easily return json for any request with the aptly named jsonify:

from flask import Flask, jsonify, make_response, request

def your_normal_code_here(email):
   return something

app = Flask(__name__)

@app.route('/api/v1.0/people', methods=['GET'])
def people_api():

    email = request.args.get('email')

    if email is None:
       make_response(jsonify({'error': 'Missing email parameter'}), 400)

    return jsonify(your_normal_code_here(email))

For more robustness and completeness of your API, try using a lightweight framework like flask-restful.

Upvotes: 3

Related Questions