Esempio n. 1
0
 def __init__(self):
   self.http_requests =  Requester()
   self.logger        =  Logger().get_logger()
   self.config        =  Config()
Esempio n. 2
0
from application import app
from application.logger import Logger

Logger().init()

# api
import application.api.status_api
import application.api.example_api

# if run with cli this is NOT executed
if __name__ == '__main__':
    app.logger.info('start application: [{0}] @ {1}:{2} in DEBUG={3}'.format(
        app.config['APP_NAME'], app.config['HTTP_HOST'], app.config['HTTP_PORT'], app.config['DEBUG']))
    app.run(host=app.config['HTTP_HOST'], port=app.config['HTTP_PORT'], debug=app.config['DEBUG'])
Esempio n. 3
0
import requests
from requests.auth import HTTPBasicAuth

from application.logger import Logger
from application.config import Config
logger = Logger().get_logger()


class Requester:
    def __init__(self):
        self.config = Config()

    def get_url(self,
                url,
                jsonify,
                headers={'content': 'application/json'},
                verify=True,
                params=None):
        # make GET request
        try:
            response = requests.get(url,
                                    headers=headers,
                                    verify=verify,
                                    params=params)
            response.raise_for_status()
        except requests.exceptions.HTTPError as e:
            logger.exception(f'Requester.get_url Exception: {e}')
            raise e

        # jsonify response
        if jsonify: