4 Commits
v0.4 ... dev

Author SHA1 Message Date
186f257704 added 8 to ambiguous characters (looks like B) 2019-07-10 19:40:14 +01:00
6c14e13d08 fix conditional if for testing 2019-07-10 19:36:22 +01:00
8db931a4c7 added spam removal 2019-07-10 19:31:11 +01:00
1067b4fc3b tidying up after dev 2019-07-06 12:52:47 +01:00
3 changed files with 32 additions and 11 deletions

View File

@@ -2,7 +2,7 @@ from flask import Flask, render_template, request
from flask_bootstrap import Bootstrap from flask_bootstrap import Bootstrap
import db import db
import config import config
import pprint import utils
app = Flask(__name__) app = Flask(__name__)
app.config.from_object(config.BaseConfig) app.config.from_object(config.BaseConfig)
@@ -20,6 +20,14 @@ def hello_world():
@app.route('/generate', methods=["POST"]) @app.route('/generate', methods=["POST"])
def generate(): def generate():
try:
ip = utils.get_ip(request)
pass
except:
ip = ''
pass
if ip != '5.135.188.148' and ip != '178.32.58.160':
try: try:
error = None error = None
identifier = my_db.get_identifier(request.form['name']) identifier = my_db.get_identifier(request.form['name'])
@@ -28,11 +36,17 @@ def generate():
identifier = '' identifier = ''
error = 'Maximum entry limit reached - please contact Sean or Joe' error = 'Maximum entry limit reached - please contact Sean or Joe'
pass pass
else:
error = None
identifier = 'F'
return render_template('generate.html', brew_name=brew_name, brew_month=brew_month, identifier=identifier, error=error) return render_template('generate.html', brew_name=brew_name, brew_month=brew_month, identifier=identifier, error=error)
@app.route('/getip')
def getip():
return utils.get_ip(request)
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0') app.run(debug=True, host='0.0.0.0')

View File

@@ -18,7 +18,7 @@ class Database:
numbers = list(range(1, 100)) numbers = list(range(1, 100))
identifiers = list(string.ascii_uppercase) + [str(item) for item in identifiers = list(string.ascii_uppercase) + [str(item) for item in
numbers] # All identifiers are treated as strings numbers] # All identifiers are treated as strings
ambiguous = ['I', 'O', 'V', '1', '5', '9', '99'] ambiguous = ['I', 'O', 'V', '1', '8', '5', '9', '99']
utils.remove_common_elements(identifiers, ambiguous) utils.remove_common_elements(identifiers, ambiguous)
return identifiers return identifiers

View File

@@ -4,3 +4,10 @@ def remove_common_elements(a, b):
if e in b: if e in b:
a.remove(e) a.remove(e)
b.remove(e) b.remove(e)
def get_ip(request):
if request.headers.getlist("X-Forwarded-For"):
return request.headers.getlist("X-Forwarded-For")[0]
else:
return request.remote_addr