Created
April 8, 2019 22:07
-
-
Save Ledoux/218d2f2661eab51091c743d43f63e9d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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