Ejemplo n.º 1
0
def main():
    app = Application()

    r = app.router
    r.add_route('/sync', synchronous)
    r.add_route('/async', asynchronous)

    app.run('localhost', 5000)
Ejemplo n.º 2
0
 def serve(self, port):
     from japronto import Application
     self.app = Application()
     self.app.router.add_route('/', self.log_handler, method='POST')
     self.app.router.add_route('/', self.read_handler, method='GET')
     self.app.router.add_route('/ping', self.ping_handler, method='POST')
     self.app.router.add_route('/', self.remove_handler, method='DELETE')
     # todo: need a file serving url
     self.app.run(port=port, debug=Params.debug)
    def start(self):
        """Start japronto web server."""

        self.app = Application()
        self.app._loop = self.loop
        self.add_routes()
        self.app.run(port=int(self.port),
                     worker_num=None,
                     reload=False,
                     debug=False)
Ejemplo n.º 4
0
 def start(self):
     self.init_self()
     app = Application()
     app.router.add_route('/init', self.init_server, methods=['POST'])
     app.router.add_route('/balance', self.check_balance, methods=['POST'])
     app.router.add_route('/txstatus',
                          self.check_txstatus,
                          methods=['POST'])
     app.router.add_route('/', self.handle_message, methods=['POST'])
     app.run(host=self.address, port=self.port)
     return self.address, self.port
Ejemplo n.º 5
0
    def __init__(self, token, prefix='/'):
        self.routes = dict()

        # setting japronto up
        app = Application()
        self.app = app
        self.router = app.router
        self.run = self.app.run

        # settings for slash commands
        self.token = token
        self.prefix = prefix.rstrip('/')

        # default Error handlers
        self.app.add_error_handler(InvalidRequest, error_handler)
        self.app.add_error_handler(InvalidToken, error_handler)
Ejemplo n.º 6
0
from japronto import Application

# Register Custom app
munis = Application()
Ejemplo n.º 7
0
    payload = merge(lb_config,
                    {"lbConfig":
                         {"portRules": [{"protocol": os.getenv('RANCHER_LB_PROTOCOL', "http"),
                                         "type": os.getenv('RANCHER_LB_TYPE', "portRule"),
                                         "hostname": "{}-{}.{}".format(RLBU_ENVIRONMENT_SLUG,
                                                                       RLBU_PROJECT_PATH_SLUG,
                                                                       os.getenv('ENV_DOMAIN')),
                                         "sourcePort": int(os.getenv('EXTERNAL_PORT', 80)),
                                         "targetPort": int(os.getenv('INTERNAL_PORT', 8080)),
                                         "serviceId": request.match_dict['service_id']}
                                        ]
                          }
                     })
    end_point = f"{V2_BETA}/projects/{os.getenv('RANCHER_ENVIRONMENT')}/loadbalancerservices/{load_balancer_id}"
    data = await put(end_point, payload)
    print(data['id'])
    hostname = "{}-{}.{}:{}".format(
        RLBU_ENVIRONMENT_SLUG,
        RLBU_PROJECT_PATH_SLUG,
        os.getenv('ENV_DOMAIN'),
        os.getenv('EXTERNAL_PORT', 80)
    )
    print(f"update lb for {hostname}")
    return request.Response(text=hostname+"\n", mime_type="text/html")


app = Application()
app.router.add_route('/{service_id}', update_load_balancer_service)
app.run(port=int(os.getenv('RLBU_PORT', 80)))
Ejemplo n.º 8
0
def start(current_bot):
    global bot
    bot = current_bot
    server = Application()
    server.router.add_route('/', handle_all_activity)
    server.run(debug=True)
Ejemplo n.º 9
0
    "accounts": ACCOUNTS,
    "credit_cards": CREDIT_CARDS,
    "customers": CUSTOMERS,
    "movements": MOVEMENTS,
    "transactions": TRANSACTIONS
}

port = int(os.getenv('PORT', 8080))
redis_host = os.environ['REDIS_SERVER']
redis_port = int(os.environ['REDIS_PORT'])
redis_password = os.environ['REDIS_PASSWORD']
redis_poolsize = int(os.environ['REDIS_POOL'])

conn = None
queue = Queue()
app = Application(debug=False)
rt = app.router


def add_months(source_date, months):
    month = source_date.month - 1 + months
    year = source_date.year + month // 12
    month = month % 12 + 1
    day = min(source_date.day, calendar.monthrange(year, month)[1])
    return datetime(year, month, day)


def serialize(process_queue):
    async def redis_serialize(process_queue):
        async def push(key, items):
            values = [json.dumps(item) for item in items]
Ejemplo n.º 10
0
from japronto import Application, RouteNotFoundException

from employeeAPI import *

api = Application()

router = api.router

# Employee Router
# list
router.add_route("/employee/list",
                 EmployeeResource.list_employee,
                 method="GET")
router.add_route("/employee/id/{id}",
                 EmployeeResource.get_employee,
                 method="GET")
router.add_route("/employee/firstname/{first_name}",
                 EmployeeResource.get_employeebyfirstname,
                 method="GET")
router.add_route("/employee/lastname/{last_name}",
                 EmployeeResource.get_employeebylastname,
                 method="GET")
router.add_route("/employee/create",
                 EmployeeResource.create_employee,
                 method="POST")

api.run(port=8000)
Ejemplo n.º 11
0
 def initApp(self):
     if self.app == None:
         self.app = Application()
Ejemplo n.º 12
0
def init(loop_param=None, port_param=None):
    """Init Janpronto server in like-oop style."""
    global loop, port, app
    loop = loop_param
    port = port_param
    app = Application()
Ejemplo n.º 13
0
import json
from app.utils import rule_util
import traceback


from app.config.logging_config import config as log_config_dict

# Setup logging
logging.config.dictConfig(log_config_dict)

info_logger = logging.getLogger('info_logger')
debug_logger = logging.getLogger('debug_logger')
error_logger = logging.getLogger('error_logger')


application = Application()


def ping(request):
    info_logger.info('/ping')
    return request.Response(code=200,
                            text=json.dumps({'message': 'Hey, I\'m running'}),
                            mime_type='application/json')


def get_rule_type(request):
    try:
        match_dict = request.match_dict
        info_logger.info('REQ: {}'.format(str(match_dict)))
        res = rule_util.get_rule_type(match_dict)
        info_logger.info('RES: {}'.format(str(res)))