Source

POS Front End Updated UI / FlaskServer.py

Full commit
#!/usr/bin/python -tt
from flask import Flask, url_for, request, redirect, jsonify, Response, render_template
from simplejson import loads, dumps
import urllib
import urllib2
import requests

app = Flask(__name__)

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

@app.route('/branchinfo')
def branchinfo():
    print 'in index'
    return render_template('branchInfo.html')

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

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

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

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

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

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

@app.route('/creditcards', methods=['POST'])
def creditcard():
    #print dir(request)
    url = 'http://lowe.jschua.com/DinoPos/api/creditcards'
    data = loads(request.data)
    print data
    data = urllib.urlencode(data)
    req = urllib2.Request(url, data)
    response = urllib2.urlopen(req)
    return response.read()

@app.route('/orders', methods=['PUT'])
def orders():
    data = loads(request.data)
    print data
    r = requests.put('http://lowe.jschua.com/DinoPos/api/orders', data)
    return r.text

@app.route('/mail', methods=['PUT'])
def mail():
    data = loads(request.data)
    print data
    r = requests.put('http://lowe.jschua.com/DinoPos/api/mail', data)
    print r.text
    return r.text

@app.route('/products', methods=['GET', 'POST'])
def products():
    from urllib import urlopen
    f = urlopen('http://lowe.jschua.com/DinoPos/api/products/')
    data = f.read()
    resp = Response(data, status=200, mimetype='application/json')
    return resp

if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True)