forked from EpicCash/epicpost
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
|
import uuid
|
||
|
from datetime import datetime
|
||
|
|
||
|
import requests
|
||
|
from flask import request, redirect, render_template, url_for, flash, make_response, send_from_directory, jsonify
|
||
|
from flask_yoloapi import endpoint, parameter
|
||
|
import json
|
||
|
|
||
|
import settings
|
||
|
from funding.factory import app, db, cache
|
||
|
from funding.orm import Address, Slate
|
||
|
|
||
|
|
||
|
@app.route('/')
|
||
|
def index():
|
||
|
return redirect(url_for('about'))
|
||
|
|
||
|
|
||
|
@app.route('/about')
|
||
|
def about():
|
||
|
return ""
|
||
|
|
||
|
|
||
|
@app.route('/postSlate', methods=['POST'])
|
||
|
@endpoint.api(
|
||
|
parameter('receivingAddress', type=str, required=True),
|
||
|
parameter('slate', type=str, required=True),
|
||
|
)
|
||
|
def postSlate(receivingAddress, slate):
|
||
|
try:
|
||
|
if receivingAddress is None or slate is None:
|
||
|
return make_response(jsonify({'status': 'failure', 'error': str("missing correct arguments")}))
|
||
|
|
||
|
try:
|
||
|
Address.add(address=receivingAddress)
|
||
|
except Exception as ex:
|
||
|
print(f'{ex}')
|
||
|
|
||
|
try:
|
||
|
Slate.add(slate=slate, receivingAddress=receivingAddress)
|
||
|
except Exception as ex:
|
||
|
print(f'{ex}')
|
||
|
|
||
|
return make_response(jsonify({'status': 'success'}))
|
||
|
except Exception as ex:
|
||
|
print(f'{ex}')
|
||
|
return make_response(jsonify({'status': 'failure', 'error': str(ex)}))
|
||
|
|
||
|
|
||
|
@app.route('/getSlates', methods=['POST'])
|
||
|
@endpoint.api(
|
||
|
parameter('receivingAddress', type=str, required=True),
|
||
|
)
|
||
|
def getSlates(receivingAddress):
|
||
|
try:
|
||
|
if receivingAddress is None:
|
||
|
return make_response(jsonify({'status': 'failure', 'error': str("missing correct arguments")}))
|
||
|
|
||
|
slates = Slate.find_slates(address=receivingAddress)
|
||
|
return make_response(jsonify({'status': 'success', 'slates': slates}))
|
||
|
|
||
|
except Exception as ex:
|
||
|
print(f'{ex}')
|
||
|
return make_response(jsonify({'status': 'failure', 'error': str(ex)}))
|