From 708b7ee669feaeebb70cc3f2cb4dbff4cf91c6ff Mon Sep 17 00:00:00 2001 From: Sam Chow Date: Wed, 9 May 2018 16:11:21 -0400 Subject: [PATCH] Add config flag that only renders new simple page --- endpoints/setup_web.py | 46 ++++++++++++++++++++++++++++++++++++ templates/config_index.html | 13 ++++++++++ test/data/test.db | Bin 1753088 -> 1753088 bytes web.py | 14 ++++++++++- 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 endpoints/setup_web.py create mode 100644 templates/config_index.html diff --git a/endpoints/setup_web.py b/endpoints/setup_web.py new file mode 100644 index 000000000..b99c3e2f8 --- /dev/null +++ b/endpoints/setup_web.py @@ -0,0 +1,46 @@ +import os +import json +import logging + +from datetime import timedelta, datetime + +from cachetools import lru_cache +from flask import (abort, redirect, request, url_for, make_response, Response, render_template, + Blueprint, jsonify, send_file, session) +from flask_login import current_user + + +from app import (app) +from endpoints.api.discovery import swagger_route_data +from endpoints.common import common_login, render_page_template +from util.cache import no_cache + + + +@lru_cache(maxsize=1) +def _get_route_data(): + return swagger_route_data(include_internal=True, compact=True) + + +def render_page_template_with_routedata(name, *args, **kwargs): + return render_page_template(name, _get_route_data(), *args, **kwargs) + +# Capture the unverified SSL errors. +logger = logging.getLogger(__name__) +logging.captureWarnings(True) + +setup_web = Blueprint('setup_web', __name__) + +STATUS_TAGS = app.config['STATUS_TAGS'] + +@setup_web.route('/', methods=['GET'], defaults={'path': ''}) +@no_cache +def index(path, **kwargs): + return render_page_template_with_routedata('config_index.html', **kwargs) + +@setup_web.errorhandler(404) +@setup_web.route('/404', methods=['GET']) +def not_found_error_display(e = None): + resp = index('', error_code=404, error_info=dict(reason='notfound')) + resp.status_code = 404 + return resp diff --git a/templates/config_index.html b/templates/config_index.html new file mode 100644 index 000000000..3abcccfec --- /dev/null +++ b/templates/config_index.html @@ -0,0 +1,13 @@ + + + + + Config mode + + +

+

What is my purpose?
+
You create tarballs
+

+ + \ No newline at end of file diff --git a/test/data/test.db b/test/data/test.db index 4b5cbd65f77db551dad7e57c671859735757c398..34d3a84ba69063630149e8390d2a9a0cc20b0d9f 100644 GIT binary patch delta 182 zcmZo@$ZlxJo*>P*ZK8}b|x)&$1Z1g6#m=GFw3)&$np1h&=$_N@sVCJUuabqy>P z49%^K4Xg|e^~_8S3=J(B-GwC>LQSVTF6I#3eqP*b)t+jLQSVTF6I#3eqt?hA5qBPp3)_nt$!{ir@C y5OV=BHxTmxF)tAF0Wm)i3jnbo5DNjZFc6CXu_zFW0kJp`O8~Lt_M`ez))N4Z_C1RL diff --git a/web.py b/web.py index fd3b1768e..7a88646c9 100644 --- a/web.py +++ b/web.py @@ -9,9 +9,21 @@ from endpoints.realtime import realtime from endpoints.web import web from endpoints.webhooks import webhooks from endpoints.wellknown import wellknown +from endpoints.setup_web import setup_web + + +import os +is_config_mode = 'FLAGGED_CONFIG_MODE' in os.environ +print('\n\n\nAre we in config mode?') +print(is_config_mode) + + +if is_config_mode: + application.register_blueprint(setup_web) +else: + application.register_blueprint(web) -application.register_blueprint(web) application.register_blueprint(githubtrigger, url_prefix='/oauth2') application.register_blueprint(gitlabtrigger, url_prefix='/oauth2') application.register_blueprint(oauthlogin, url_prefix='/oauth2')