Compare commits
2 Commits
ba69c2a97f
...
89e802aa57
Author | SHA1 | Date | |
---|---|---|---|
89e802aa57 | |||
06af95ce57 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
__pycacahe__/*
|
||||
freeriders/__pycacahe__/*
|
||||
|
@ -11,6 +11,6 @@ def predict(timestamp):
|
||||
base_timestamp = 1694003498
|
||||
step = 8
|
||||
|
||||
ticket = base_ticket + (int(time.time()) - base_timestamp) * step
|
||||
ticket = base_ticket + (timestamp - base_timestamp) * step
|
||||
return ticket
|
||||
|
||||
|
@ -5,12 +5,11 @@ from freeriders.models import Tickets
|
||||
from datetime import datetime
|
||||
import time
|
||||
|
||||
PREDICTTIMERANGE = 60 * 80
|
||||
|
||||
@app.route('/sms', methods=['GET'])
|
||||
def sms():
|
||||
if request.method == 'GET':
|
||||
timenow = time.time()
|
||||
timenow = int(time.time())
|
||||
|
||||
try:
|
||||
lastticket = Tickets.query.order_by(Tickets.timestamp.desc()).first()
|
||||
@ -21,7 +20,7 @@ def sms():
|
||||
lastticket = formatprefix10(lastticket.ticket)
|
||||
date = datetime.now()
|
||||
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)
|
||||
except:
|
||||
return 'Error retriving last ticket'
|
||||
@ -30,6 +29,7 @@ def sms():
|
||||
|
||||
@app.route('/submit', methods=['POST', 'GET'])
|
||||
def submit():
|
||||
PREDICTTIMERANGE = 60 * 80
|
||||
if request.method == 'GET':
|
||||
return render_template('submit.html')
|
||||
elif request.method == 'POST':
|
||||
@ -37,9 +37,13 @@ def submit():
|
||||
ticket_input = request.form['ticket']
|
||||
|
||||
if ticket_input.isdigit() and len(ticket_input) == 10 :
|
||||
if ticket_input < predict(timenow + PREDICTTIMERANGE ) and ticket_input > predict(timenow - PREDICTTIMERANGE ) :
|
||||
if int(ticket_input) < predict(timenow + PREDICTTIMERANGE ) and int(ticket_input) > predict(timenow - PREDICTTIMERANGE ) :
|
||||
ticket = Tickets(ticket = int(ticket_input), timestamp = timenow)
|
||||
else:
|
||||
print(int(ticket_input))
|
||||
print(predict(timenow - PREDICTTIMERANGE))
|
||||
print(predict(timenow + PREDICTTIMERANGE))
|
||||
print(predict(timenow))
|
||||
return 'Ticket number is in unexpected range.'
|
||||
else:
|
||||
return 'Ticket format is wrong. Only 10 digits allowed.'
|
||||
|
Loading…
Reference in New Issue
Block a user