Compare commits

..

1 Commits

Author SHA1 Message Date
Tim Van Baak 440301d737 Change gunicorn to an optional dependency 2021-02-18 17:09:10 -08:00
4 changed files with 2 additions and 31 deletions

5
poetry.lock generated
View File

@ -164,11 +164,8 @@ email = ["email-validator"]
ipaddress = ["ipaddress"]
locale = ["Babel (>=1.3)"]
[extras]
dev = ["gunicorn"]
[metadata]
content-hash = "e4930aaf62df0a261424129ab0d89af96ea4e19f80b76c7c6fbcb25c491a213d"
content-hash = "899cd435824d023104e5842da0f85bf3d82cf4a83137abfe19b7d817e1a12974"
lock-version = "1.0"
python-versions = "^3.8"

View File

@ -14,9 +14,6 @@ gunicorn = {version = "^20.0.4", optional = true}
[tool.poetry.dev-dependencies]
mypy = "^0.800"
[tool.poetry.extras]
dev = ["gunicorn"]
[tool.poetry.scripts]
redstring-check = "redstring.parser:main"
redstring-server = "redstring.server:cli"

View File

@ -1,14 +1,2 @@
import logging
import redstring.parser
import redstring.server
formatter = logging.Formatter('[{asctime}] [{process}] [{levelname}] {message}', '%Y-%m-%d %H:%M:%S %z', style='{')
handler = logging.StreamHandler()
handler.setFormatter(formatter)
handler.setLevel(logging.DEBUG)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
import redstring.server

View File

@ -3,7 +3,6 @@ Logic for serving a collection of documents through a web frontend.
"""
import argparse
import json
import logging
import os
import random
import string
@ -48,8 +47,6 @@ class LoginForm(FlaskForm):
CONFIG_ENVVAR = 'REDSTRING_CONFIG'
logger = logging.getLogger(__name__)
app = Flask(__name__)
app.secret_key = ''.join(random.choices(string.ascii_uppercase + string.digits, k=32))
@ -63,16 +60,10 @@ def check_password(app, password):
Checks if a password is correct
"""
password_file = app.config['password_file']
if not os.path.isfile(password_file):
logger.debug('Authentication failed: no password file found')
with open(password_file) as f:
real_password = f.read().strip()
correct = password == real_password
del real_password
if correct:
logger.debug('Authentication successful')
else:
logger.debug('Authentication failed: password incorrect')
return correct
@ -232,6 +223,4 @@ def cli():
def wsgi():
config_path = os.environ.get(CONFIG_ENVVAR) or '/etc/redstring.conf'
config = read_config(app, config_path)
logger.setLevel(logging.DEBUG)
logger.debug(f'Loaded config from {config_path}: {config}')
return app