It is very amazing to make APIs and use them anywhere in development but how to make them ?? 🤔🤔
What is API?
APIs, or Application Programming Interfaces, have revolutionized the way software applications communicate with each other. APIs enable different applications and systems to share data and services seamlessly, making it possible for businesses and individuals to create new and innovative products and services.
The beauty of APIs lies in their ability to unlock the power of data and services that were previously inaccessible or difficult to use. With APIs, developers can access and use data from a wide range of sources, including social media platforms, government databases, financial institutions, and more. They can also use APIs to build new applications that leverage the services and capabilities of existing systems, such as payment processing, messaging, and location services.
Install Flask and Streamlit Dependencies
pip install Flask
pip install streamlit
Let's divide the code into two files. The first file is to run the server so that it can expose through API. And second file is to show output on the web page through Streamlit.
In the server.py file, the data function is used to execute queries and return the responses. It can be modified with the use of services that can provide responses of Deep Learning models or Artificial Intelligence models.
To host API, run Server.py in the terminal and keep it running so we can check the API on the web page.
It will create the API at http://localhost:1111/check_api
Now, come to the main.py file which is going to use to run streamlit library. As we want to render the response on the web page.
To run main.py, run the below code in terminal
streamlit run main.py
Hurray, we have created an API. Now, it is your turn to make APIs for Deep Learning models or for other queries. You can check out my GitHub repo here.