2018-06-26 21:48:25 +00:00
|
|
|
from datetime import datetime
|
|
|
|
from flask import request, redirect, Response, abort, render_template, url_for, flash, make_response, send_from_directory, jsonify
|
|
|
|
from flask.ext.login import login_user , logout_user , current_user , login_required, current_user
|
|
|
|
from flask_yoloapi import endpoint, parameter
|
|
|
|
import settings
|
2018-09-05 22:27:26 +00:00
|
|
|
from funding.factory import app, db_session
|
|
|
|
from funding.orm.orm import Proposal, User
|
2018-06-26 21:48:25 +00:00
|
|
|
|
|
|
|
@app.route('/api/1/proposals')
|
|
|
|
@endpoint.api(
|
2018-07-04 17:50:36 +00:00
|
|
|
parameter('status', type=int, location='args', default=1),
|
2018-06-26 21:48:25 +00:00
|
|
|
parameter('cat', type=str, location='args'),
|
|
|
|
parameter('limit', type=int, location='args', default=20),
|
|
|
|
parameter('offset', type=int, location='args', default=0)
|
|
|
|
)
|
|
|
|
def api_proposals_get(status, cat, limit, offset):
|
|
|
|
try:
|
|
|
|
proposals = Proposal.find_by_args(status=status, cat=cat, limit=limit, offset=offset)
|
|
|
|
except Exception as ex:
|
|
|
|
print(ex)
|
|
|
|
return 'error', 500
|
2018-07-12 11:35:54 +00:00
|
|
|
return [p.json for p in proposals]
|
|
|
|
|
|
|
|
@app.route('/api/1/convert/wow-usd')
|
|
|
|
@endpoint.api(
|
2018-09-05 22:27:26 +00:00
|
|
|
parameter('amount', type=int, location='args', required=True)
|
2018-07-12 11:35:54 +00:00
|
|
|
)
|
2018-09-05 22:27:26 +00:00
|
|
|
def api_coin_usd(amount):
|
|
|
|
from funding.bin.utils import Summary, coin_to_usd
|
2018-07-12 11:35:54 +00:00
|
|
|
prices = Summary.fetch_prices()
|
2018-09-05 22:27:26 +00:00
|
|
|
return jsonify(usd=coin_to_usd(amt=amount, btc_per_coin=prices['coin-btc'], usd_per_btc=prices['btc-usd']))
|