Skip to content
Chethan Yadav
Work

Engineering/2024/Active

AI Text Summarizer

A simple AI text summarizer app that uses the Hugging Face Inference API to summarize text.

JavaScriptExpressNode.js

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 — sends text_to_summarize to facebook/bart-large-cnn via the Hugging Face Inference API and returns the generated summary
  • POST /texttoimage — sends text_to_imagegen to black-forest-labs/FLUX.1-dev and returns the generated image
  • Static frontend served directly from Express (public/index.html for summarization, public/texttoimage.html for 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 install

Copy the example environment file and add a Hugging Face access token:

cp example.env .env
ACCESS_TOKEN=your_hugging_face_access_token

Then start the server:

npm run start

The 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' }),
});

View on GitHub ↗