-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmulligan.py
67 lines (50 loc) · 1.76 KB
/
mulligan.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
55
56
57
58
59
60
61
62
63
64
65
66
67
# A mulligan app developed for Vicious Syndicate
from flask import Flask, render_template, request, jsonify
from shuffler import *
from simulator import *
app = Flask(__name__)
@app.route('/_simulate', methods=['POST'])
def simulate():
"""Takes the deckcode and executes the mulligan function"""
#exampledeckcode "AAECAf0ECE3FBJAH7Ae%2FCIivAqG3ApbHAgvAAbsClQOrBO0ElgWjtgLXtgLpugLBwQKYxAIA"
deckcode = request.form.get('deckcode', 0, type=str)
sim = simulator()
sim.simulate_mulligan(deckcode)
result = sim.results
if result:
return jsonify({result})
return jsonify({'error': 'Bad Deckstring!'})
##Testing the case where we do not have a dynamic code to check for the response between the server and the webpage
@app.route('/_smallsim')
def testsim():
sim = simulator()
sim.simulate_mulligan("AAECAf0ECE3FBJAH7Ae%2FCIivAqG3ApbHAgvAAbsClQOrBO0ElgWjtgLXtgLpugLBwQKYxAIA")
result = sim.results["hand_url"]
return jsonify(result)
##Example for adding numbers serverside
@app.route('/_add_numbers')
def add_numbers():
"""Add two numbers server side, ridiculous but well..."""
a = request.args.get('a', 0, type=int)
b = request.args.get('b', 0, type=int)
return jsonify(result=a + b)
@app.route('/')
def homepage():
return render_template("index.html")
@app.route('/mulligan')
def mulligan():
return render_template("mulligan.html")
##More testing below here
@app.route('/supertest')
def index():
return render_template('form.html')
@app.route('/process', methods=['POST'])
def process():
email = request.form['email']
name = request.form['name']
if name and email:
newName = name[::-1]
return jsonify({'name' : newName})
return jsonify({'error' : 'Missing data!'})
if __name__ == "__main__":
app.run()