| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #!/usr/bin/env python3
- import json
- import urllib
- import datetime
- from db import db
- from flask import Flask, jsonify, request
- app = Flask(__name__)
- PORT = 8981
- BASE_PATH="/back" #changes based on webserver
- d = db()
- @app.route(BASE_PATH + '/cliente/<_hash>')
- def client(_hash):
- out=d.client(_hash)
- if out is None:
- return "{}", 400
- return json.dumps(out)
- @app.route(BASE_PATH + '/productos/<_hash>')
- def products(_hash):
- c=d.client(_hash)
- if c is None:
- return "{}", 400
- out=d.products()
- return json.dumps(out)
- @app.route(BASE_PATH + '/pedido', methods=["POST"])
- def pedido():
- t = datetime.datetime.now()
- r = request.get_json()
- productos = r["pedido"]["productos"]
- cliente = r["pedido"]["cliente"]
- d.pedido(productos,cliente)
- return "{}"
- if __name__ == '__main__':
- app.run(host="0.0.0.0",port=PORT, debug=True)
|