Skip to content

Commit 55d1d70

Browse files
committed
Upgrading everything
1 parent 29c0b51 commit 55d1d70

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.9.5-alpine3.13
2+
3+
WORKDIR /usr/src/app
4+
5+
COPY requirements.txt ./
6+
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
COPY . .
9+
10+
CMD [ "python", "./commit.py" ]

commit.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import random
44
import re
55
import json
6+
from typing import Dict, List
67

78
try:
89
from hashlib import md5
@@ -24,14 +25,16 @@
2425

2526
humans_file = os.path.join(os.path.dirname(__file__), 'static', 'humans.txt')
2627
messages_file = os.path.join(os.path.dirname(__file__), 'commit_messages.txt')
27-
messages = {}
28+
messages: Dict[str, str] = {}
2829

2930
# Create a hash table of all commit messages
30-
with open(messages_file) as messages_input:
31+
with open(messages_file, 'r', encoding='utf-8') as messages_input:
3132
for line in messages_input.readlines():
32-
messages[md5(line).hexdigest()] = line
33+
messages[md5(line.encode('utf-8')).hexdigest()] = line
3334

34-
with open(humans_file) as humans_input:
35+
names: List[str] = []
36+
37+
with open(humans_file, 'r', encoding='utf-8') as humans_input:
3538
humans_content = humans_input.read()
3639
for line in humans_content.split("\n"):
3740
if "Name:" in line:
@@ -41,6 +44,8 @@
4144
else:
4245
names.append(data.split(" ")[0])
4346

47+
print(names)
48+
4449
num_re = re.compile(r"XNUM([0-9,]*)X")
4550

4651
def fill_line(message):
@@ -76,7 +81,7 @@ def fill_line(message):
7681
class MainHandler(tornado.web.RequestHandler):
7782
def get(self, message_hash=None):
7883
if not message_hash:
79-
message_hash = random.choice(messages.keys())
84+
message_hash = random.choice(list(messages.keys()))
8085
elif message_hash not in messages:
8186
raise tornado.web.HTTPError(404)
8287

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Tornado==4.2.0
1+
Tornado==6.1

runtime.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-2.7.15
1+
python-3.9.5

0 commit comments

Comments
 (0)