2021-CGTicker/README.md

5.1 KiB

Ticker System

This project is a client-server solution for managing and distributing news tickers using RSS feeds. It consists of a Flask-based web server for feed management and a Python client for fetching and processing ticker data.

Features

  • Web Interface (Flask Server)

    • Add, edit, and manage ticker titles via a web form.
    • Stores ticker data in RSS XML files.
    • Basic authentication for access control.
  • Python Client

    • Fetches RSS feed data from the server.
    • Parses and saves each ticker title as a separate text file.

Folder Structure

└── CGTicker 
    └── Flask (Server Side)/ 
        ├── Run.py
        ├── .env
        └── templates/
            └── logo/
                ├── favicon.ico
                ├── logo.png
            ├── input.xml 
        └── ... 
    
    └── RSS Reader (Client Side)/ 
        └── TickerFiles/
        ├── ticker.py
        ├── .env
    
    ├── README.md

Usage

Option 1: Using exe file

You can run the client as a standalone executable if you have packaged it (for example, using PyInstaller). This is useful for users who do not have Python installed, see the section below on how to do this.

1. Prepare the .env file

  • Make sure your .env file (with the correct server address and settings) is in the same directory as the .exe file.

  • Example RSS Reader (Client Side)/.env:

    SERVER_ADDRESS=http://your-server-ip
    TICKER_FOLDER=./TickerFiles/
    XML_ROUTE=/xml/rss/input.xml
    SLEEP_SECONDS=20
    
  • Example Flask (Server Side)/.env:

    FLASK_SECRET_KEY=_3213sdsau2n2_23
    USER=admin
    PASS=pass
    

    where FLASK_SECRET_KEY can be any random string, ensure randomness for security

2. Run the Executable

  • Open a terminal and navigate to the directory containing the .exe file (e.g., ticker.exe).

  • Run the executable:

    .\ticker.exe
    
  • The client will fetch the RSS feed from the server and save each ticker title as a separate text file in the TickerFiles directory, just like the Python script.

Note:

  • The .env file must be present in the same directory as the .exe at runtime.

  • If you update the server address or other settings, edit the .env file accordingly.

  • If you need to create the .exe, you can use a tool like PyInstaller:

    pyinstaller --onefile ticker.py
    

Option 2: Using Python files

1. Start the Flask Server

  1. Open a terminal and navigate to the Flask (Server Side) directory.

  2. Ensure you have Python and the required packages installed (flask, python-dotenv).

  3. Set up your .env file with your desired credentials and secret key (see example below).

  4. Run the server:

    python Run.py
    

The server will be available at locally at the servers IP at port 80 (defaut http port)

2. Access the Web Interface

  • Open your browser and go to your server's IP address.
  • Log in with the username and password set in your .env file.
  • Use the web form to add or edit ticker titles. These will be saved to templates/input.xml.

3. Run the Python Client

  1. Open a terminal on your client server (where ticker files need to be saved) and navigate to the RSS Reader (Client Side) directory.

  2. Ensure you have Python and the required packages installed (feedparser, python-dotenv).

  3. Set up your .env file with the server address and other settings (see example below).

  4. Run the client:

    python ticker.py
    

The client will fetch the RSS feed from the server and save each ticker title as a separate text file in the TickerFiles directory.

Compiling to an Executable with PyInstaller

1. Install PyInstaller

Open a terminal and run:

pip install pyinstaller

2. Compile the Python Script

Navigate to the directory containing your script (e.g., ticker.py for the client or Run.py for the server) and run:

pyinstaller --onefile ticker.py

3. Prepare the Output Directory

  • After building, the .exe will be in the dist/ folder.
  • Copy your .exe file back into the same folder as the .py file

4. Run the Executable

Open a terminal in the output directory and run:

./ticker.exe

or for the server:

./Run.exe

Note:

  • The .env file must be present in the same directory as the .exe at runtime.
  • If you update the server address or other settings, edit the .env file accordingly.

Customizing Logo and Favicon Icons

You can easily switch the logo and favicon used by the web interface by replacing the files in the templates/logo/ directory.

  • Logo:

    • To change the logo, simply replace templates/logo/logo.png with your new image (keep the filename the same).
  • Favicon:

    • The favicon is referenced as templates/logo/favicon.png and also served as /favicon.ico for browser compatibility.
    • To change the favicon, replace templates/logo/favicon.ico