Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 186f257704 | |||
| 6c14e13d08 | |||
| 8db931a4c7 | |||
| 1067b4fc3b |
22
web/app.py
22
web/app.py
@@ -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')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user