Render reddit markdown, poll tildes better, add utils

This commit is contained in:
2019-08-28 04:13:02 +00:00
parent 10d4ec863e
commit 23cdbc9292
6 changed files with 76 additions and 30 deletions

View File

@@ -6,11 +6,10 @@ logging.basicConfig(
import copy
import threading
import time
import random
import shelve
import string
import feed
from utils import gen_rand_id
from flask import abort, Flask, request
from flask_cors import CORS
@@ -26,6 +25,7 @@ with shelve.open(DATA_FILE) as db:
news_ref_to_id = db.get('news_ref_to_id', {})
news_cache = db.get('news_cache', {})
flask_app = Flask(__name__)
cors = CORS(flask_app)
@@ -54,9 +54,6 @@ web_thread = threading.Thread(target=flask_app.run, kwargs={'port': 33842})
web_thread.setDaemon(True)
web_thread.start()
def gen_rand_id():
return ''.join(random.choice(string.ascii_uppercase) for _ in range(4))
def new_id():
nid = gen_rand_id()
with shelve.open(DATA_FILE) as db:
@@ -92,7 +89,7 @@ try:
news_story = news_cache[update_id]
feed.update_story(news_story)
time.sleep(1)
time.sleep(3)
news_index += 1
if news_index == CACHE_LENGTH: news_index = 0