Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[project]
name = "weblog"
version = "1.0.0"
description = "Web logger."
authors = [{ name = "bjorn6699" }]
requires-python = ">=3.14"
readme = "README.md"
license = { file = "LISENSE" }
dependencies = [
" blinker==1.9.0",
"click==8.3.1",
"crossfiledialog==1.1.0",
"Flask==3.1.2",
"itsdangerous==2.2.0",
"Jinja2==3.1.6",
"MarkupSafe==3.0.3",
"pygtail==0.14.0",
"Werkzeug==3.1.4",
"pywin32==311",
]

[project.scripts]
weblogs = "weblogs.weblogs:main"

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
where = ["src"]
Empty file added src/weblogs/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 12 additions & 8 deletions weblogs/weblogs.py → src/weblogs/weblogs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
from pathlib import Path
import time
import re
import crossfiledialog
Expand All @@ -12,13 +12,14 @@
# [ ] comment
# [ ] separate README


weblogs = Flask(__name__)

config = weblogs.config
config.update(
PROGRAM_NAME='MyProject',
FILE_DISPLAY_PATH='static/example.log',
FILE_FULL_PATH=os.path.abspath('static/example.log'),
FILE_DISPLAY_PATH= 'static/example.log',
FILE_FULL_PATH=str(Path(__file__).parent / "static" / "example.log"),
FONT_SIZE=10,
REFRESH_RATE=1000,
SMOOTHNESS=0.01,
Expand Down Expand Up @@ -148,8 +149,7 @@ def index():

# Remove the log offset file each time the root url is refreshed
offset_file_path = config['FILE_FULL_PATH'] + ".offset"
if os.path.isfile(offset_file_path):
os.remove(offset_file_path)
Path(offset_file_path).unlink(missing_ok=True)

return render_template(
template_name_or_list='logs.html',
Expand Down Expand Up @@ -194,13 +194,13 @@ def open_file():

path = crossfiledialog.open_file(
title="Pick a new log file !",
start_dir=os.path.dirname(os.getcwd()),
start_dir=Path.cwd().parent,
filter=["*.log", "*.txt", "*.doc", "*.docx", "*.md", "*.rtf", "*.msg"]
)
# Updating the weblogs configuration with the relative path of the new selected file (only if there is one !)
if path:
config['FILE_FULL_PATH'] = path
config['FILE_DISPLAY_PATH'] = os.path.relpath(path)
config['FILE_DISPLAY_PATH'] = str(Path(path).relative_to(Path.cwd()))

return redirect("/")

Expand All @@ -222,5 +222,9 @@ def show_flask_env():
return env


if __name__ == "__main__":
def main():
weblogs.run(host= '127.0.0.1', port= 5000, debug=True)


if __name__ == "__main__":
main()
9 changes: 0 additions & 9 deletions weblogs/requirements.txt

This file was deleted.