This commit is contained in:
parent
70dc17dd75
commit
2774b8e84a
45
README.md
45
README.md
@ -9,6 +9,7 @@ This project is a Python daemon that connects to your Gmail account, searches fo
|
||||
- Parses the email to extract the actual PDF download link.
|
||||
- Downloads the PDF file and saves it to a local `data` directory.
|
||||
- Runs as a daemon, checking for new emails periodically.
|
||||
- Hosts the downloaded PDF files on a local HTTP server with a styled listing.
|
||||
|
||||
## Requirements
|
||||
- Python 3.7+
|
||||
@ -49,45 +50,39 @@ This project is a Python daemon that connects to your Gmail account, searches fo
|
||||
|
||||
## Usage
|
||||
|
||||
To run the script as a daemon, use one of the following methods:
|
||||
### Daemon Script
|
||||
|
||||
### 1. Using Python Daemon Library (Recommended for Simplicity)
|
||||
To run the email-checking script as a daemon, use one of the following methods:
|
||||
|
||||
1. **Using Python Daemon Library (Recommended for Simplicity)**:
|
||||
```bash
|
||||
python3 email_pdf_downloader.py
|
||||
```
|
||||
|
||||
The script will run in the background, checking for new emails every 5 minutes.
|
||||
|
||||
### 2. Using Systemd (Linux)
|
||||
2. **Using Systemd (Linux)**:
|
||||
- Create a Systemd Service file `/etc/systemd/system/email_reader.service` with appropriate configurations.
|
||||
- Enable and start the service.
|
||||
|
||||
1. **Create a Systemd Service**:
|
||||
- Create a file `/etc/systemd/system/email_reader.service`:
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Email PDF Downloader Daemon
|
||||
### PDF Server
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/python3 /path/to/email_pdf_downloader.py
|
||||
Restart=always
|
||||
User=your_username
|
||||
WorkingDirectory=/path/to/project
|
||||
This project includes a local HTTP server for hosting downloaded PDF files. It runs on port 8000 by default and lists all PDF files in the `data` directory in a styled HTML format.
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
- **Start the Server**:
|
||||
```python
|
||||
python3 pdf_server.py
|
||||
```
|
||||
|
||||
2. **Enable and Start the Service**:
|
||||
```bash
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable email_reader.service
|
||||
sudo systemctl start email_reader.service
|
||||
```
|
||||
### PDF Server Code Explanation
|
||||
|
||||
3. **Check Status**:
|
||||
```bash
|
||||
sudo systemctl status email_reader.service
|
||||
```
|
||||
The `PDFServer` class is a custom HTTP server that serves PDF files from a specified directory. It includes a custom HTML-styled listing for an enhanced user experience.
|
||||
|
||||
- **Class Initialization**: Sets the directory and port for serving files.
|
||||
- **PDFRequestHandler**: A custom request handler that filters and displays only PDF files with a dark-themed, material-styled HTML format.
|
||||
- **`list_directory`**: Overrides the directory listing method to filter only PDF files and style the output.
|
||||
- **`generate_html`**: Generates HTML content, listing available PDF files with a custom dark theme.
|
||||
- **`send_html_response`**: Sends the styled HTML response to the client.
|
||||
|
||||
## Configuration
|
||||
- **SCOPES**: OAuth scopes for Gmail API access.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user