Skip to content

Commit

Permalink
Merge pull request #174 from Guovin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Guovin authored Jun 28, 2024
2 parents 9e876f0 + e90b964 commit fff0b55
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 55 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.8-slim

WORKDIR /app

COPY . /app

# RUN pip install --trusted-host pypi.python.org Flask

EXPOSE 80

ENV NAME World

CMD ["python", "./main.py"]
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tqdm = "*"
async-timeout = "*"
pyinstaller = "*"
aiohttp = "*"
flask = "*"

[requires]
python_version = "3.8"
117 changes: 116 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
open_update = True
source_file = "demo.txt"
final_file = "result.txt"
favorite_list = [
Expand Down
22 changes: 18 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
from tqdm import tqdm
from tqdm.asyncio import tqdm_asyncio
from time import time
from flask import Flask, render_template_string

app = Flask(__name__)

config_path = resource_path("user_config.py")
default_config_path = resource_path("config.py")
Expand All @@ -42,6 +45,13 @@ def __init__(self):
self.total = 0
self.start_time = None

@app.route("/")
def show_result():
user_final_file = getattr(config, "final_file", "result.txt")
with open(user_final_file, "r", encoding="utf-8") as file:
content = file.read()
return render_template_string("<pre>{{ content }}</pre>", content=content)

def check_info_data(self, cate, name):
if self.channel_data.get(cate) is None:
self.channel_data[cate] = {}
Expand Down Expand Up @@ -246,7 +256,11 @@ def stop(self):


if __name__ == "__main__":
update_source = UpdateSource()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(update_source.start())
if config.open_update:
update_source = UpdateSource()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(update_source.start())
github_actions = os.environ.get("GITHUB_ACTIONS")
if not github_actions:
app.run(host="0.0.0.0", port=80)
Loading

0 comments on commit fff0b55

Please sign in to comment.