fixed web layout
This commit is contained in:
parent
a6b5e560fb
commit
52f1565772
3
.gitignore
vendored
3
.gitignore
vendored
@ -176,4 +176,5 @@ cython_debug/
|
||||
|
||||
*.json
|
||||
*.pdf
|
||||
data/*
|
||||
data/*
|
||||
*.html
|
||||
@ -6,6 +6,8 @@ import os
|
||||
from webSimple import generate_pdf_list_html
|
||||
from email_pdf_downloader import read_emails
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
def run_daemon():
|
||||
while True:
|
||||
try:
|
||||
@ -14,8 +16,8 @@ def run_daemon():
|
||||
except Exception as e:
|
||||
logging.error(f"An error occurred: {e}")
|
||||
|
||||
directory = '/scrapy/amznMailConverter/data'
|
||||
output_file = os.path.join(directory, "/scrapy/amznMailConverter/index.html")
|
||||
directory = SCRIPT_DIR+'/data'
|
||||
output_file = os.path.join(directory, SCRIPT_DIR+"/index.html")
|
||||
generate_pdf_list_html(directory, output_file)
|
||||
time.sleep(60) # Sleep for 1 minute between checks
|
||||
|
||||
|
||||
@ -20,15 +20,15 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
def get_credentials():
|
||||
creds = None
|
||||
if os.path.exists('/scrapy/amznMailConverter/token.json'):
|
||||
creds = Credentials.from_authorized_user_file('token.json', SCOPES)
|
||||
if os.path.exists(SCRIPT_DIR+'/token.json'):
|
||||
creds = Credentials.from_authorized_user_file(SCRIPT_DIR+'/token.json', SCOPES)
|
||||
if not creds or not creds.valid:
|
||||
if creds and creds.expired and creds.refresh_token:
|
||||
creds.refresh(Request())
|
||||
else:
|
||||
flow = InstalledAppFlow.from_client_secrets_file('/scrapy/amznMailConverter/credentials.json', SCOPES)
|
||||
flow = InstalledAppFlow.from_client_secrets_file(SCRIPT_DIR+'/credentials.json', SCOPES)
|
||||
creds = flow.run_local_server(port=0)
|
||||
with open('/scrapy/amznMailConverter/token.json', 'w') as token:
|
||||
with open(SCRIPT_DIR+'/token.json', 'w') as token:
|
||||
token.write(creds.to_json())
|
||||
return creds
|
||||
|
||||
|
||||
25
webSimple.py
25
webSimple.py
@ -1,7 +1,6 @@
|
||||
#!/scrapy/venvs/amznMailConverter/bin/python
|
||||
|
||||
import os
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
def generate_pdf_list_html(directory, output_file="pdf_list.html"):
|
||||
@ -14,24 +13,26 @@ def generate_pdf_list_html(directory, output_file="pdf_list.html"):
|
||||
# Get the current timestamp
|
||||
generation_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
# HTML content with dark and blue-themed Material Design styling
|
||||
# HTML content with updated styling
|
||||
html_content = f'''<html>
|
||||
<head>
|
||||
<title>PDF Files</title>
|
||||
<style>
|
||||
body {{ font-family: Arial, sans-serif; background-color: #121212; color: #e0e0e0; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; }}
|
||||
.container {{ max-width: 600px; background: #1e1e1e; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.5); border-radius: 8px; padding: 20px; text-align: center; }}
|
||||
h2 {{ color: #bb86fc; font-size: 24px; margin-bottom: 20px; }}
|
||||
body {{ font-family: "Courier New", Courier, monospace; background-color: #0d1b2a; color: #e0e0e0; margin: 0; padding: 100px; }}
|
||||
.container {{ max-width: 800px; background: #1b2631; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.5); border-radius: 12px; padding: 30px; margin: auto; margin-top: 40px; }}
|
||||
h2 {{ color: #00bfff; font-size: 28px; margin-bottom: 10px; }}
|
||||
.separator {{ border-top: 2px solid #00bfff; margin-bottom: 50px; }}
|
||||
ul {{ list-style-type: none; padding: 0; }}
|
||||
li {{ margin: 10px 0; }}
|
||||
a {{ text-decoration: none; color: #03dac6; font-weight: bold; padding: 10px 15px; border-radius: 5px; transition: background-color 0.2s ease; }}
|
||||
a:hover {{ background-color: #333; color: #bb86fc; }}
|
||||
.footer {{ margin-top: 20px; font-size: 12px; color: #666; }}
|
||||
li {{ margin: 15px 0; }}
|
||||
a {{ text-decoration: none; color: #00bfff; font-weight: bold; padding: 10px 15px; border-radius: 5px; transition: background-color 0.2s ease; }}
|
||||
a:hover {{ background-color: #005f7f; color: #ffffff; }}
|
||||
.footer {{ margin-top: 60px; font-size: 12px; color: #bbb; }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>Available PDF Files for Download</h2>
|
||||
<div class="separator"></div>
|
||||
<ul>'''
|
||||
|
||||
for name in file_list:
|
||||
@ -51,4 +52,8 @@ def generate_pdf_list_html(directory, output_file="pdf_list.html"):
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
|
||||
# Usage
|
||||
if __name__ == "__main__":
|
||||
directory = 'amznMailConverter/data'
|
||||
output_file = os.path.join(directory, "pdf_list.html")
|
||||
generate_pdf_list_html(directory, output_file)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user