import random import string import datetime import json from flask_api import status from flask import request from flask import Response from flask_restplus import Resource from smartweb_service import settings from smartweb_service.api.restplus import api from smartweb_service.api.common.common_service import validate_api_key from smartweb_service.api.common.common_service import getTime log = logging.getLogger(__name__) ns = api.namespace('1/hive', description='Implements hive storage services') @ns.route('/add') class Add(Resource): def post(self): """ Returns Hash key of the content added. """ api_key = request.headers.get('api_key') api_status = validate_api_key(api_key) if not api_status: data = {"error message":"API Key could not be verified","status":401, "timestamp":getTime(),"path":request.url} return Response(json.dumps(data), status=401, mimetype='application/json'
import logging import requests import json from flask import jsonify from flask import request from flask import Response from flask_api import FlaskAPI, status, exceptions from flask_restplus import Resource from smartweb_service import settings from smartweb_service.api.restplus import api from smartweb_service.api.common.common_service import validate_api_key from smartweb_service.api.common.common_service import getTime log = logging.getLogger(__name__) ns = api.namespace('1/service/sidechain/did', description='Has did services') @ns.route('/createDid') class CreateDid(Resource): def get(self): """ Returns the DID created """ api_key = request.headers.get('api_key') api_status = validate_api_key(api_key) if not api_status: data = { "error message": "API Key could not be verified", "status": 401, "timestamp": getTime(),
import requests import json import datetime from flask import jsonify from flask import request from flask import Response from flask_api import FlaskAPI, status, exceptions from flask_restplus import Resource from smartweb_service import settings from smartweb_service.api.restplus import api from smartweb_service.api.common.common_service import validate_api_key from smartweb_service.api.common.common_service import getTime log = logging.getLogger(__name__) ns = api.namespace('1/service/mainchain', description='Has wallet services') @ns.route('/createWallet') class CreateWallet(Resource): def get(self): """ Returns the wallet created """ api_key = request.headers.get('api_key') api_status = validate_api_key(api_key) if not api_status: data = { "error message": "API Key could not be verified", "status": 401, "timestamp": getTime(),
import requests import random import string import datetime import json from flask import request from flask import Response from flask_restplus import Resource from smartweb_service import settings from smartweb_service.api.restplus import api from smartweb_service.api.common.common_service import getTime log = logging.getLogger(__name__) ns = api.namespace('1/common', description='Implements common services') @ns.route('/generateAPIKey') class Generate(Resource): def get(self): """ Returns API key of length 20. """ stringLength = 32 api_key = ''.join( random.choice(string.ascii_letters + string.digits) for i in range(stringLength)) data = { "API Key": api_key, "status": 200,
import requests from requests import Request, Session import json from flask import jsonify from flask import request from flask import Response from flask_api import FlaskAPI, status, exceptions from flask_restplus import Resource from smartweb_service import settings from smartweb_service.api.restplus import api from smartweb_service.api.common.common_service import validate_api_key from smartweb_service.api.common.common_service import getTime log = logging.getLogger(__name__) ns = api.namespace('1/mainchain', description='Has mainchain node services') @ns.route('/getblockhash', methods=['POST']) class GetBlockHash(Resource): def post(self): """ Returns the getblockhash """ api_key = request.headers.get('api_key') api_status = validate_api_key(api_key) if not api_status: data = { "error message": "API Key could not be verified", "status": 401, "timestamp": getTime(),
import random import string import datetime import json from flask import request from flask import Response from flask_restplus import Resource from smartweb_service import settings from smartweb_service.api.restplus import api from smartweb_service.api.common.common_service import validate_api_key from smartweb_service.api.common.common_service import getTime log = logging.getLogger(__name__) ns = api.namespace('1/console', description='Implements console functionalities') @ns.route('/upload') class Upload(Resource): def post(self): """ Upload a file to hive. """ api_key = request.headers.get('api_key') api_status = validate_api_key(api_key) if not api_status: data = {"error message":"API Key could not be verified","status":401, "timestamp":getTime(),"path":request.url} return Response(json.dumps(data), status=401, mimetype='application/json'