Skip to content

Instantly share code, notes, and snippets.

@Ledoux
Created April 8, 2019 22:07
Show Gist options
  • Save Ledoux/218d2f2661eab51091c743d43f63e9d1 to your computer and use it in GitHub Desktop.
Save Ledoux/218d2f2661eab51091c743d43f63e9d1 to your computer and use it in GitHub Desktop.
from flask import current_app as app, jsonify, request
from models import Offer, PcObject, Stock
@app.route('/offers/<id>', methods=['GET'])
@login_required
def get_offer(id):
offer = load_or_404(Offer, id)
return jsonify(offer._asdict(include=["stocks"]))
@app.route('/stocks', methods=['POST'])
@login_required
def post_stock():
stock = Stock()
stock.populateFromDict(request.json)
PcObject.check_and_save(stock)
return jsonify(stock._asdict())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment