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
.envfile (with the correct server address and settings) is in the same directory as the.exefile. -
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=passwhere 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
.exefile (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
TickerFilesdirectory, just like the Python script.
Note:
-
The
.envfile must be present in the same directory as the.exeat runtime. -
If you update the server address or other settings, edit the
.envfile 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
-
Open a terminal and navigate to the
Flask (Server Side)directory. -
Ensure you have Python and the required packages installed (
flask,python-dotenv). -
Set up your
.envfile with your desired credentials and secret key (see example below). -
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
.envfile. - Use the web form to add or edit ticker titles. These will be saved to
templates/input.xml.
3. Run the Python Client
-
Open a terminal on your client server (where ticker files need to be saved) and navigate to the
RSS Reader (Client Side)directory. -
Ensure you have Python and the required packages installed (
feedparser,python-dotenv). -
Set up your
.envfile with the server address and other settings (see example below). -
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
.exewill be in thedist/folder. - Copy your
.exefile back into the same folder as the.pyfile
4. Run the Executable
Open a terminal in the output directory and run:
./ticker.exe
or for the server:
./Run.exe
Note:
- The
.envfile must be present in the same directory as the.exeat runtime. - If you update the server address or other settings, edit the
.envfile 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.pngwith your new image (keep the filename the same).
- To change the logo, simply replace
-
Favicon:
- The favicon is referenced as
templates/logo/favicon.pngand also served as/favicon.icofor browser compatibility. - To change the favicon, replace
templates/logo/favicon.ico
- The favicon is referenced as