Compare commits
No commits in common. "89e802aa574efc761e4d20533455f0677d508b36" and "ba69c2a97fa8a96ee567c23b2a819a0c6ce19c41" have entirely different histories.
89e802aa57
...
ba69c2a97f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1 @@
|
|||||||
__pycacahe__/*
|
__pycacahe__/*
|
||||||
freeriders/__pycacahe__/*
|
|
||||||
|
@ -11,6 +11,6 @@ def predict(timestamp):
|
|||||||
base_timestamp = 1694003498
|
base_timestamp = 1694003498
|
||||||
step = 8
|
step = 8
|
||||||
|
|
||||||
ticket = base_ticket + (timestamp - base_timestamp) * step
|
ticket = base_ticket + (int(time.time()) - base_timestamp) * step
|
||||||
return ticket
|
return ticket
|
||||||
|
|
||||||
|
@ -5,11 +5,12 @@ from freeriders.models import Tickets
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
PREDICTTIMERANGE = 60 * 80
|
||||||
|
|
||||||
@app.route('/sms', methods=['GET'])
|
@app.route('/sms', methods=['GET'])
|
||||||
def sms():
|
def sms():
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
timenow = int(time.time())
|
timenow = time.time()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lastticket = Tickets.query.order_by(Tickets.timestamp.desc()).first()
|
lastticket = Tickets.query.order_by(Tickets.timestamp.desc()).first()
|
||||||
@ -20,7 +21,7 @@ def sms():
|
|||||||
lastticket = formatprefix10(lastticket.ticket)
|
lastticket = formatprefix10(lastticket.ticket)
|
||||||
date = datetime.now()
|
date = datetime.now()
|
||||||
datenow = f'{formatprefix2(date.day)}.{formatprefix2(date.month)}.{date.year}'
|
datenow = f'{formatprefix2(date.day)}.{formatprefix2(date.month)}.{date.year}'
|
||||||
timenow = f'{formatprefix2(date.hour)}:{formatprefix2(date.minute)}:{formatprefix2(date.second)}'
|
timenow = f'{formatprefix2(date.hour)}:{formatprefix2(date.minute)}:formatprefix2{date.second}'
|
||||||
return render_template('sms.html', ticket = lastticket, date = datenow, time = timenow)
|
return render_template('sms.html', ticket = lastticket, date = datenow, time = timenow)
|
||||||
except:
|
except:
|
||||||
return 'Error retriving last ticket'
|
return 'Error retriving last ticket'
|
||||||
@ -29,7 +30,6 @@ def sms():
|
|||||||
|
|
||||||
@app.route('/submit', methods=['POST', 'GET'])
|
@app.route('/submit', methods=['POST', 'GET'])
|
||||||
def submit():
|
def submit():
|
||||||
PREDICTTIMERANGE = 60 * 80
|
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
return render_template('submit.html')
|
return render_template('submit.html')
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
@ -37,13 +37,9 @@ def submit():
|
|||||||
ticket_input = request.form['ticket']
|
ticket_input = request.form['ticket']
|
||||||
|
|
||||||
if ticket_input.isdigit() and len(ticket_input) == 10 :
|
if ticket_input.isdigit() and len(ticket_input) == 10 :
|
||||||
if int(ticket_input) < predict(timenow + PREDICTTIMERANGE ) and int(ticket_input) > predict(timenow - PREDICTTIMERANGE ) :
|
if ticket_input < predict(timenow + PREDICTTIMERANGE ) and ticket_input > predict(timenow - PREDICTTIMERANGE ) :
|
||||||
ticket = Tickets(ticket = int(ticket_input), timestamp = timenow)
|
ticket = Tickets(ticket = int(ticket_input), timestamp = timenow)
|
||||||
else:
|
else:
|
||||||
print(int(ticket_input))
|
|
||||||
print(predict(timenow - PREDICTTIMERANGE))
|
|
||||||
print(predict(timenow + PREDICTTIMERANGE))
|
|
||||||
print(predict(timenow))
|
|
||||||
return 'Ticket number is in unexpected range.'
|
return 'Ticket number is in unexpected range.'
|
||||||
else:
|
else:
|
||||||
return 'Ticket format is wrong. Only 10 digits allowed.'
|
return 'Ticket format is wrong. Only 10 digits allowed.'
|
||||||
|
Loading…
Reference in New Issue
Block a user