SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from flask import Flask, Blueprint, jsonify
  2. from utils import NLogger
  3.  
  4. logger = NLogger.create_logger('nimbus.api_service')
  5.  
  6.  
  7. class ApiService(service.Service):
  8.  
  9.     def __init__(self, app_factory):
  10.         self.app_factory = app_factory
  11.         self.web_app = Flask(__name__)
  12.         self.api_bp = Blueprint('api', __name__)
  13.         self.config = Config.to_dict()
  14.  
  15.     @inlineCallbacks
  16.     def startService(self):
  17.         logger.info("Starting web api service")
  18.  
  19.         yield self.setup_routes()
  20.         yield self.setup_web_server()
  21.  
  22.  
  23.     def stopService(self):
  24.         pass
  25.  
  26.     @inlineCallbacks
  27.     def setup_web_server(self):
  28.         yield self.web_app.register_blueprint(self.api_bp, url_prefix='/api')
  29.         yield self.web_app.run('127.0.0.1', 8081)
  30.  
  31.  
  32.     """ ROUTER """
  33.     def setup_routes(self):
  34.         @self.api_bp.route('/test', methods=['GET'])
  35.         def test():
  36.             return "xd"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top