Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @api.route('/currencyData')
- class Currency(Resource):
- def get(self):
- lastData = CurrencyData.query.order_by(-CurrencyData.id).first()
- return lastData #json
- @api.marshal_with(CurrencyData, envelope='resource')
- def put(self):
- if request.form:
- try:
- print(request.form)
- c = CurrencyData(eur=request.form.get("eur"), usd=request.form.get("usd"), jpy=request.form.get("jpy"), gbp=request.form.get("gbp"), dataDateTime=date.today())
- print("Pobrane dane: ", c)
- db.session.add(c)
- db.session.commit()
- return c #pomyślna operacja
- except Exception as e:
- print("Failed to add new data: ", e)
- return 500 #błąd serwera
- return 400 #jakiś błąd użytkownika
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement