From d31855785d9b9e4baa109853a617067b33281763 Mon Sep 17 00:00:00 2001 From: monoid Date: Tue, 25 Jul 2023 18:18:06 +0900 Subject: [PATCH] chore: remove unused. --- README.md | 2 ++ app.py | 24 ------------------ deno.json | 1 + gen.py | 35 +++++--------------------- templates/Lists.html | 60 -------------------------------------------- templates/index.html | 40 ----------------------------- 6 files changed, 9 insertions(+), 153 deletions(-) delete mode 100644 app.py delete mode 100644 templates/Lists.html delete mode 100644 templates/index.html diff --git a/README.md b/README.md index 7fc4a90..7876b0f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # Stock +[![Made with Fresh](https://fresh.deno.dev/fresh-badge.svg)](https://fresh.deno.dev) + 주식 데이터 수집 및 선별하는 파이썬 코드입니다. diff --git a/app.py b/app.py deleted file mode 100644 index eeecaa4..0000000 --- a/app.py +++ /dev/null @@ -1,24 +0,0 @@ -import flask -import argparse - -parser = argparse.ArgumentParser(description="Stock web server") -parser.add_argument("--port", type=int, default=12001, help="port number") -parser.add_argument("--host", type=str, default="0.0.0.0", help="host address") -parser.add_argument("--debug", action="store_true", help="debug mode") - -app = flask.Flask(__name__) -app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 - -@app.route("/dist/") -def distServe(m:str): - return flask.send_from_directory("dist", m) - -@app.route("/") -def index(): - import pages - return flask.render_template("index.html", pages = pages.GenLists) - -if __name__ == '__main__': - args = parser.parse_args() - app.run(host=args.host, port=args.port, debug=args.debug) - diff --git a/deno.json b/deno.json index ecff41f..d87aafd 100644 --- a/deno.json +++ b/deno.json @@ -2,6 +2,7 @@ "lock": false, "tasks": { "start": "deno run -A --watch=static/,routes/ dev.ts", + "prod_start": "deno run -A main.ts", "update": "deno run -A -r https://fresh.deno.dev/update ." }, "lint": { diff --git a/gen.py b/gen.py index a5675c0..7f60e25 100644 --- a/gen.py +++ b/gen.py @@ -5,7 +5,6 @@ import sqlite3 from typing import Dict, List from render import * import db as database -from jinja2 import Environment, PackageLoader, select_autoescape import pandas as pd import tqdm @@ -145,7 +144,6 @@ def collect(data: DataStore, collector: OutputCollector, corp: database.KRXCorp d5 = d(5) d20 = d(20) d25 = d(25) - d30 = d(30) d45 = d(45) d60 = d(60) d120 = d(120) @@ -248,8 +246,6 @@ def collect(data: DataStore, collector: OutputCollector, corp: database.KRXCorp #rsi_signal = macd.loc[::-1].ewm(span=7).mean().loc[::-1] parser = argparse.ArgumentParser(description="주식 검색 정보를 출력합니다.") -parser.add_argument("--format", "-f", choices=["json", "html"], default="html", -help="출력 포맷을 지정합니다. 기본값은 html입니다.") parser.add_argument("--dir", "-d", default=".", help="출력할 폴더를 지정합니다.") parser.add_argument("--corp", "-c", help="주식 코드를 지정합니다. 지정하지 않으면 kosdaq과 kospi만 검색합니다.") parser.add_argument("--fullSearch", help="모든 주식을 검색합니다.", action='store_true') @@ -268,10 +264,6 @@ if __name__ == "__main__": if args.corp: krx_corps = [corp for corp in krx_corps if corp.Code == args.corp] - env = Environment( - loader=PackageLoader('render', 'templates'), - autoescape=select_autoescape(['html', 'xml']) - ) collector = OutputCollector() prepareCollector(collector) @@ -281,25 +273,10 @@ if __name__ == "__main__": dataStore.clearCache() for k,v in collector.data.items(): - if args.format == "json": - data = json.dumps(v.toDict(), indent=4, ensure_ascii=False) - if args.printStdout: - print(k) - print(data) - else: - with open(os.path.join(args.dir, k + ".json"), "w", encoding="UTF-8") as f: - f.write(data) + data = json.dumps(v.toDict(), ensure_ascii=False) + if args.printStdout: + print(k) + print(data) else: - template = env.get_template("Lists.html") - - days = v.corpListByDate.keys() - days = list(days) - days.sort(reverse=True) - days = days[:5] - - html = template.render(collected=v, title=k, days=days, lastUpdate=datetime.date.today().isoformat()) - if args.printStdout: - print(html) - else: - with open(os.path.join(args.dir, k + ".html"), "w", encoding="UTF-8") as f: - f.write(html) \ No newline at end of file + with open(os.path.join(args.dir, k + ".json"), "w", encoding="UTF-8") as f: + f.write(data) \ No newline at end of file diff --git a/templates/Lists.html b/templates/Lists.html deleted file mode 100644 index 45e1520..0000000 --- a/templates/Lists.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - Stock - - - -
-

{{title}} Stock List

-

{{lastUpdate}}

-
- {{collected.description}} -
-
- {% for day in days|reverse %} -
{{ day }}
- {% endfor %} - {% for day in days|reverse %} - {% set corplist = collected.corpListByDate[day] %} -
{% for item in corplist %} - {% endfor %} -
- {% endfor %} -
-
- - \ No newline at end of file diff --git a/templates/index.html b/templates/index.html deleted file mode 100644 index 0be3681..0000000 --- a/templates/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - Stock - - - -
-

Main

-
- {% for p in pages %} - {{p.name}} - {% endfor %} -
-
- -