Python IP Lookup Application with Flask

In this Python tutorial we are going to learn about IP Lookup Application with Flask, so for creating 

IP Lookup Application with Flask we are going to use ipapi library.

 

 

 

Learn Django REST Framework for Beginner in Python 

 

 

Also you can read Django articles in the below links

1: Django Pagination Complete Example

2: Django Sending Email to Gmail Account 

3: Build News Application in Django 

4: Django Aggregation Example

5: Django User Authentication Framework 

6: Django IP Finder Application 

 

 

 

 

Installation 

First of all you need to install ipapi library, you can use pip for the installation.

 

 

 

 

OK now we are going to use Flask library for this, Flask is one of the best and micro web

development framework in Python, make sure that you have already installed Flask if you

have not installed you can just use pip for the installation.

 

 

 

Now let’s create our Project Structure in Flask, first of all you need to open your favorite IDE, in

this article iam using Pycharm IDE, create a New Project in Pycharm IDE, iam going to call it 

FlaskIPFinder, after creating of the Project we need to create a Python file, iam going to call

it flaskipfinder.py, also you need to create a templates folder, in the templates folder create 

two html files, the first one is base.html and the second one is index.html.

 

 

 

This is our flask Project Structure.

Flask Project Structure
Flask Project Structure

 

 

 

 

OK now open open your flaskipfinder.py file and you need to add this code in that file.

basically in the Index view function we are going to first get the input from the user,

right now we have not created our html code, after that we use our ipapi library for finding the

IP locations and information. also you need to send the information in your index.html.

 

 

 

 

 

Now this is our base.html. also we have used Bootstrap CDN link in here.

 

templates/base.html

 

 

 

 

 

And this is the index.html, basically we have a text input field for searching IP Address, also we

are rendering the data in our index.html file.

 

templates/index.html

 

 

 

 

 

So now run your Flask Project and go to http://localhost:5000/, and this is the result, first

it will show your IP Address, also you can search for an specific IP Address in Flask.

 

Python IP Lookup Application with Flask
Python IP Lookup Application with Flask

 

 

 

 

 

 

Also you can watch the complete video for this article

Subscribe and Get Free Video Courses & Articles in your Email

 

Comments are closed.

Share via
Copy link
Powered by Social Snap
×