flask webapp, registered as a consul client """ from flask import Flask, jsonify import logging from consulclient import register, deregister import os PORT = 8000 # Flask Application API_V1 = '/api/v1/' logging.basicConfig(level=logging.DEBUG) app = Flask(__name__, static_url_path='') register(PORT, None, "webapp") @app.route(API_V1 + "health", methods=['GET']) def health(): """ health """ return jsonify(health=True) @app.route("/") def index(): """ hello world """
from flask import Flask, jsonify import logging import os from consulclient import register, deregister from redis import StrictRedis import time PORT = 8000 API_V1 = '/api/v1/' logging.basicConfig(level=logging.DEBUG) app = Flask(__name__, static_url_path='') register(PORT, os.environ['TAGS'].split(',') if os.environ.has_key('TAGS') else None) REDIS = StrictRedis(host='redis', port=6379, db=0) # REST endpoints @app.route(API_V1 + "health", methods=['GET']) def health(): """ healthcheck endpoint """ return jsonify(health=True) @app.route(API_V1 + "count") def index(): """ RESTful web service
from flask import Flask, jsonify, request import logging import os from consulclient import register, deregister from redis import StrictRedis import datetime import time PORT = 8000 API_V1 = '/api/v1/' logging.basicConfig(level=logging.DEBUG) app = Flask(__name__, static_url_path='') register(PORT, os.environ['TAGS'].split(',') if os.environ.has_key('TAGS') else None) REDIS = StrictRedis(host='redis', port=6379, db=0) # REST endpoints @app.route(API_V1 + "health", methods=['GET']) def health(): """ healthcheck endpoint """ return jsonify(health=True) @app.route(API_V1 + "ip") def index(): """ RESTful webservice
flask webapp, registered as a consul client """ from flask import Flask, jsonify import logging from consulclient import register, deregister import os PORT = 8000 # Flask Application API_V1 = '/api/v1/' logging.basicConfig(level=logging.DEBUG) app = Flask(__name__, static_url_path='') register(PORT, None, "webapp") @app.route(API_V1 + "health", methods=['GET']) def health(): """ health """ return jsonify(health=True) @app.route("/") def index(): """ hello world """ return 'Hello World! 1.0'