Add config flag that only renders new simple page
This commit is contained in:
parent
44bb000fa5
commit
708b7ee669
4 changed files with 72 additions and 1 deletions
46
endpoints/setup_web.py
Normal file
46
endpoints/setup_web.py
Normal file
|
@ -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
|
13
templates/config_index.html
Normal file
13
templates/config_index.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Config mode</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>
|
||||||
|
<div>What is my purpose?</div>
|
||||||
|
<div>You create tarballs</div>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
Binary file not shown.
14
web.py
14
web.py
|
@ -9,9 +9,21 @@ from endpoints.realtime import realtime
|
||||||
from endpoints.web import web
|
from endpoints.web import web
|
||||||
from endpoints.webhooks import webhooks
|
from endpoints.webhooks import webhooks
|
||||||
from endpoints.wellknown import wellknown
|
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(githubtrigger, url_prefix='/oauth2')
|
||||||
application.register_blueprint(gitlabtrigger, url_prefix='/oauth2')
|
application.register_blueprint(gitlabtrigger, url_prefix='/oauth2')
|
||||||
application.register_blueprint(oauthlogin, url_prefix='/oauth2')
|
application.register_blueprint(oauthlogin, url_prefix='/oauth2')
|
||||||
|
|
Reference in a new issue