Engineering/2024/Active
AI Text Summarizer
A simple AI text summarizer app that uses the Hugging Face Inference API to summarize text.
Overview
Built while working through Postman Academy's "AI Text Summarizer App" project, this is a small Express server that wraps the Hugging Face Inference API behind two endpoints — text summarization and text-to-image generation. It exists mainly to keep an API key off the client: the browser never talks to Hugging Face directly, it hits a local Express route, which attaches the token server-side and forwards the request.
The summarizer runs on Facebook's bart-large-cnn model; a second, less-advertised route runs Black Forest Labs' FLUX.1-dev model to turn a text prompt into an image. Both are straightforward POST-in, response-out proxies with no queueing, caching, or rate limiting — appropriate for a learning project, not a production service.
Key Features
POST /summarize— sendstext_to_summarizetofacebook/bart-large-cnnvia the Hugging Face Inference API and returns the generated summaryPOST /texttoimage— sendstext_to_imagegentoblack-forest-labs/FLUX.1-devand returns the generated image- Static frontend served directly from Express (
public/index.htmlfor summarization,public/texttoimage.htmlfor image generation) — no separate frontend build step - Minimal dependency footprint:
express,axios,dotenv
Installation
git clone https://github.com/chethanyadav456/AI-Text-Summarizer-App.git
cd AI-Text-Summarizer-App
npm installCopy the example environment file and add a Hugging Face access token:
cp example.env .envACCESS_TOKEN=your_hugging_face_access_tokenThen start the server:
npm run startThe app listens on http://localhost:3000 and serves the static frontend from public/.
Usage
// Summarize text
fetch('http://localhost:3000/summarize', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text_to_summarize: 'Long article text goes here...' }),
});
// Generate an image from a text prompt
fetch('http://localhost:3000/texttoimage', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text_to_imagegen: 'A watercolor painting of a lighthouse' }),
});