Skip to content

Repository files navigation

Newspaper AI

Flask newspaper editor that scrapes article URLs, sends the text to a local Qwen AI server, and returns publication-ready summaries. The AI also powers contextual chat and editing endpoints so users can rewrite, expand, or insert polished article copy from the browser editor.

What It Does

Newspaper AI is split into two small Flask services:

  • desktop_AI_server.py runs the local AI model API using Qwen through Hugging Face Transformers.
  • app.py runs the browser newspaper editor, scrapes article URLs, and calls the AI server for summaries, chat, and edits.

Use the home page to paste a news article URL and generate a polished summary, or open the editor manually to write and revise article copy with AI help.

Requirements

  • Python 3.10 or newer
  • Enough disk space to download the Qwen model on first run
  • Optional but recommended: NVIDIA GPU with CUDA for faster local generation

Setup

Create and activate a virtual environment:

python -m venv venv

macOS or Linux:

source venv/bin/activate

Windows PowerShell:

venv\Scripts\Activate.ps1

Windows Command Prompt:

venv\Scripts\activate.bat

Install the web app dependencies:

pip install -r requirements.txt

Install the desktop AI server dependencies:

pip install -r desktop_requirements.txt

Running The App

Open two terminals from the project folder.

Terminal 1, start the AI server:

python desktop_AI_server.py

Terminal 2, start the newspaper web app:

python app.py

Then open this in your browser:

http://localhost:5001

The manual editor is available at:

http://localhost:5001/editor

Configuration

If both services run on the same computer, start the web app with:

macOS or Linux:

AI_SERVER_URL=http://127.0.0.1:5000 python app.py

Windows PowerShell:

$env:AI_SERVER_URL="http://127.0.0.1:5000"; python app.py

Windows Command Prompt:

set AI_SERVER_URL=http://127.0.0.1:5000
python app.py

Useful environment variables:

  • AI_SERVER_URL sets where the web app sends AI requests. Default: http://192.168.86.243:5000
  • APP_HOST and APP_PORT control the web app host and port. Default: 0.0.0.0:5001
  • AI_HOST and AI_PORT control the AI server host and port. Default: 0.0.0.0:5000
  • QWEN_MODEL changes the Hugging Face model. Default: Qwen/Qwen2.5-3B-Instruct
  • MAX_NEW_TOKENS controls response length. Default: 900

Files

  • app.py: browser app, article scraping, and AI request routes
  • desktop_AI_server.py: local Qwen model server
  • templates/: Flask HTML pages
  • static/: browser JavaScript and CSS
  • requirements.txt: browser app Python packages
  • desktop_requirements.txt: local AI server Python packages

About

Flask newspaper editor that scrapes article URLs, sends the text to a local Qwen AI server, and returns publication-ready summaries. The AI also powers contextual chat and editing endpoints so users can rewrite, expand, or insert polished article copy from the browser editor.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages