This Django REST API project provides endpoints for web scraping and text summarization using Mistral AI
- Web scraping endpoint: Scrapes text content from a given URL
- Text summarization endpoint: Generates a summary of provided text using OpenAI's GPT-3
- Python
- Django
- Django REST Framework
- Beautiful Soup
- Requests
- OpenAI Python library
- React
-
Install the required packages: pip install -r requirements.txt
-
Set up your OpenAI API key:
- Create a
.env
file in the project root - Add your Mistral AI API_KEY
- Create a
-
Apply database migrations: python manage.py migrate
-
Run the development server: python manage.py runserver
Send a POST request to /api/scrape/
with a JSON body:
{ "url": "https://example.com" }
The API will return the scraped text content.
Send a POST request to /api/summarize/
with a JSON body:
{ "input_data": "Your long text to be summarized goes here..." }
The API will return a summary of the provided text.
- POST /api/scrape/: Web scraping endpoint
- POST /api/summary/: Text summarization endpoint
The API returns appropriate HTTP status codes and error messages for various scenarios:
- 200 OK: Successful operation
- 400 Bad Request: Invalid input data
- 500 Internal Server Error: Server-side errors (e.g., issues with web scraping or OpenAI API)