This Python microservice, built using FastAPI, serves as a lightweight interface to interact with Wikipedia. It enables users to search for terms, retrieve specific Wikipedia pages, and extract important phrases from these pages.
Before you begin, ensure you have the following installed:
- Python 3.x
- pip (Python package installer)
To install and run this microservice on your local machine, follow these steps:
-
Clone the Repository:
git clone https://github.com/python-dev-og/CICD-API-microservices.git
-
Navigate to the Project Directory:
cd [Your Project Directory]
-
Install Dependencies:
- FastAPI: A modern, fast web framework for building APIs with Python.
- Uvicorn: An ASGI server for running FastAPI applications.
- Wikipedia-API: A Python wrapper for Wikipedia's search and content APIs.
- TextBlob: A library for processing textual data.
Run the following command to install these packages:
pip install fastapi uvicorn wikipedia-api textblob
After installing the dependencies, you can start the server with this command:
uvicorn main:app --reload
The --reload
flag enables auto-reloading of the server on code changes.
Access the following endpoints through your browser or an API testing tool like Postman:
-
Root Endpoint (
GET /
): Returns a welcome message and API usage instructions. -
Search Wikipedia (
GET /search/{value}
): Search for a term in Wikipedia. Replace{value}
with your search term. -
Retrieve Wikipedia Page (
GET /wiki/{name}
): Fetch a specific Wikipedia page. Replace{name}
with the name of the page. -
Retrieve Phrases (
GET /phrase/{name}
): Extract key phrases from a Wikipedia page. Replace{name}
with the name of the page.
-
To search Wikipedia for "Python":
http://localhost:8080/search/Python
-
To retrieve the Wikipedia page for "Python":
http://localhost:8080/wiki/Python
-
To extract phrases from the Wikipedia page "Python":
http://localhost:8080/phrase/Python
List of Python packages required:
- FastAPI
- Uvicorn
- Wikipedia-API
- TextBlob
Contributions to improve the application are welcome. Please follow these steps to contribute:
- Fork the repository.
- Create a new branch for your feature (
git checkout -b feature/AmazingFeature
). - Commit your changes (
git commit -m 'Add some AmazingFeature'
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a pull request.
MIT License
Happy Coding!