From 9b0f67b5ef04a273760cece932073c352b1c80a1 Mon Sep 17 00:00:00 2001 From: Marek Baczynski Date: Sat, 24 Nov 2018 22:52:47 +0200 Subject: [PATCH] order site 1 --- order_site /server.py | 27 +++++++++ order_site /static/picker.js | 58 +++++++++++++++++++ order_site /static/style.css | 0 order_site /templates/index.html | 97 ++++++++++++++++++++++++++++++++ 4 files changed, 182 insertions(+) create mode 100644 order_site /server.py create mode 100644 order_site /static/picker.js create mode 100644 order_site /static/style.css create mode 100644 order_site /templates/index.html diff --git a/order_site /server.py b/order_site /server.py new file mode 100644 index 0000000..f532c51 --- /dev/null +++ b/order_site /server.py @@ -0,0 +1,27 @@ +import json +import requests +from flask import Flask +from flask import render_template, request, Response +import xmlrpc.client + +s = xmlrpc.client.ServerProxy('http://localhost:8000') +app = Flask(__name__) + + +@app.route('/', strict_slashes=False) +def index(): + return render_template('index.html') + +@app.route('/order', methods=['POST']) +def order(): + candy1 = int(request.form['candy1']) + candy2 = int(request.form['candy2']) + candy3 = int(request.form['candy3']) + candy4 = int(request.form['candy4']) + print ("test {} {} {} {} ".format(candy1, candy2, candy3, candy4)) + return '{"status":"ok"}' + #s.new_order(params) + + +if __name__ == '__main__': + app.run('0.0.0.0') diff --git a/order_site /static/picker.js b/order_site /static/picker.js new file mode 100644 index 0000000..337e9ef --- /dev/null +++ b/order_site /static/picker.js @@ -0,0 +1,58 @@ +$(document).ready(function(){ + +var quantitiy=0; + $('.quantity-right-plus').click(function(e){ + + // Stop acting like a button + e.preventDefault(); + // Get the field name + var quantity = parseInt($('#quantity').val()); + + // If is not undefined + + $('#quantity').val(quantity + 1); + + + // Increment + + }); + + $('.quantity-left-minus').click(function(e){ + // Stop acting like a button + e.preventDefault(); + // Get the field name + var quantity = parseInt($('#quantity').val()); + + // If is not undefined + + // Increment + if(quantity>0){ + $('#quantity').val(quantity - 1); + } + }); + +}); + +function submitOrder(){ + + var data = new FormData(); + data.append('candy1', $('#candy1').val()); + data.append('candy2', $('#candy2').val()); + data.append('candy3', $('#candy3').val()); + data.append('candy4', $('#candy4').val()); + + $.ajax({ + url: 'order', + type: 'POST', + cache: false, + data: data, + contentType: false, + processData: false, + success: function() { + alert("ok") + }, + fail: function() { + alert("not ok") + }, + }); +} \ No newline at end of file diff --git a/order_site /static/style.css b/order_site /static/style.css new file mode 100644 index 0000000..e69de29 diff --git a/order_site /templates/index.html b/order_site /templates/index.html new file mode 100644 index 0000000..09395e5 --- /dev/null +++ b/order_site /templates/index.html @@ -0,0 +1,97 @@ + + + + +Alepa Twitch Grabs Candy + + + + + + + + +
+
+

Simple Quantity increment buttons with Javascript

+
+ Tasty treats +
+ + + + + + + + +
+
+
+ Sweet snacks +
+ + + + + + + + +
+
+ +
+ Chocolaty candy +
+ + + + + + + + +
+
+ +
+ Good something +
+ + + + + + + +
+
+ +
+
+ +
+
+
+
+ + + +