@JacksonAiken3/

Lottery Royale

Python

The one-of-a-kind game that's easy to learn, hard to win, where your success depends on your skills and luck.

fork
loading
Files
  • main.py
  • assets
  • templates
  • requirements.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import ujson as json
from flask import Flask, render_template, send_from_directory, request, abort
from datetime import datetime

datasets = []


app = Flask(__name__)

@app.route('/datasets/<int:number>')
def get_dataset_n(number):
	if number < 1:
		abort(404)
	elif len(datasets) < number:
		abort(404)
	else:
		dataset = datasets[number-1]
		return render_template('dataset.html', dataset=dataset['data'], dataset_meta=dataset['meta'])

@app.route('/')
def homepage():
	return render_template('homepage.html')

@app.route('/assets/<path:path>')
def send_asset(path):
	return send_from_directory('./assets', path)

@app.route('/upload', methods=['POST'])
def receive_dataset():
	dataset_json = json.loads(request.files['file'].read().decode('utf-8'))['data']

	dataset_json = [{'draw_date':datetime.strptime(datapoint[8].split('T')[0], '%Y-%m-%d').strftime('%a., %B %d %Y').lower(), 'number':datapoint[9], 'mega':datapoint[10], 'mega_mult':datapoint[11], 'id':dataset_json.index(datapoint)+1, 'date':datapoint[8].split('T')[0]} for datapoint in dataset_json]

	
	dataset_meta = {
		'name': request.form.get('dataset_name').lower(),
		'upload time utc': str(datetime.utcnow()).split('.')[0],
		'id': len(datasets)+1
	}

	dataset = {'data':dataset_json,'meta':dataset_meta}

	datasets.append(dataset)
	return '<meta http-equiv="refresh" content="0; url=/datasets/{}" />'.format(dataset['meta']['id'])

@app.route('/about')
def about_lotto():
	return render_template('about.html')

@app.route('/all')
def all_datasets():
	return render_template('all.html', datasets=datasets)

app.run(host='0.0.0.0', port=8080)