Loading examples/flask_example/Dockerfile +0 −3 Original line number Diff line number Diff line Loading @@ -6,14 +6,11 @@ WORKDIR /tmp # build context is defined in docker-compose.flask.yaml COPY scripts scripts COPY config config COPY api api COPY tests tests COPY main.py main.py COPY requirements.txt requirements.txt # Add extra needed os packages here # RUN apt-get update --fix-missing && apt-get install postgresql-client curl pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl gcc -y RUN apt-get update --fix-missing && apt-get install pkg-config postgresql-client curl procps -y RUN set -eux && pip3 install --upgrade pip Loading examples/flask_example/api/app.py +5 −4 Original line number Diff line number Diff line Loading @@ -6,14 +6,15 @@ from flask_jwt_extended import JWTManager from flask_restx import Api, Resource from datetime import timedelta from api.routes import api as base_api from api.routes import routes from api.swaggerui.namespaces.api_doc_namespace import api as api_namespace def create_app(): app = Flask(__name__, static_folder='/tmp/templates', template_folder='/tmp/templates') app = Flask(__name__, static_folder='/tmp/templates', template_folder='/tmp/api/templates') app.config['TEMPLATES_AUTO_RELOAD'] = True app.register_blueprint(base_api.blueprint, url_prefix='/') app.register_blueprint(routes.blueprint, url_prefix='/') api = Api(app, version='1.0', title='Web APIs', description='SWAGGERUI Documentation for web APIs', doc='/doc/') api.add_namespace(api_namespace) Loading examples/flask_example/api/swaggerui/namespaces/api_doc_namespace.py +4 −3 Original line number Diff line number Diff line from flask_restx import Namespace, Resource import flask_restx from routes import api as api_routes from api.routes import routes import flask from flask import request api = Namespace('api', 'Loads Hello World') @api.route("/") @api.doc() class GetBaseRoute(Resource): def get(self): return api_routes.home() return routes.home() # TODO # Make swagger from flask-restx Loading examples/flask_example/api/templates/sample_page.html +28 −27 Original line number Diff line number Diff line <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Fetch and Display Text</title> <script> async function fetchAndDisplay(url, targetId) { try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } const text = await response.text(); document.getElementById(targetId).textContent = text; } catch (error) { document.getElementById(targetId).textContent = `Error: ${error.message}`; } } </script> </head> <body> <h1>Fetch and Display Text</h1> <title>Sample Page</title> <link rel= "stylesheet" href="{{ url_for('static', filename='styles/base.css') }}"> <!-- Button for "/" --> <button onclick="fetchAndDisplay('http://localhost:8420/', 'output-home')">Healthcheck</button> <div id="output-home" style="margin-top: 10px; color: blue;"></div> <!-- Button for "/api" --> <button onclick="fetchAndDisplay('http://localhost:8420/api', 'output-api')">Home</button> <div id="output-api" style="margin-top: 10px; color: green;"></div> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <main> <section id="login-card"> <img id="doe-logo" src="{{ url_for('static', filename='images/doeLogo.d97bf559.png') }}" width="123" alt="DOE Logo" title="DOE Logo" /> <span id="login-title__wrapper"> <h1 id="login-title">Sample Page</h1> <img id="login-title__icon" src="{{ url_for('static', filename='images/padlock.svg') }}" alt="padlock icon" title="Padlock icon" /> </span> {% block content %} <a href="/api/test" class="btn btn-primary">Login</a> {% endblock %} </section> </main> </body> </html> examples/flask_example/docker-compose.override.yml +2 −2 Original line number Diff line number Diff line Loading @@ -19,5 +19,5 @@ services: - FAST_REFRESH=false - FLASK_HOST=http://localhost:9090 volumes: - ./web:/tmp - ./web/scripts:/tmp/scripts - ./scripts:/tmp/scripts - ./api:/tmp/api Loading
examples/flask_example/Dockerfile +0 −3 Original line number Diff line number Diff line Loading @@ -6,14 +6,11 @@ WORKDIR /tmp # build context is defined in docker-compose.flask.yaml COPY scripts scripts COPY config config COPY api api COPY tests tests COPY main.py main.py COPY requirements.txt requirements.txt # Add extra needed os packages here # RUN apt-get update --fix-missing && apt-get install postgresql-client curl pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl gcc -y RUN apt-get update --fix-missing && apt-get install pkg-config postgresql-client curl procps -y RUN set -eux && pip3 install --upgrade pip Loading
examples/flask_example/api/app.py +5 −4 Original line number Diff line number Diff line Loading @@ -6,14 +6,15 @@ from flask_jwt_extended import JWTManager from flask_restx import Api, Resource from datetime import timedelta from api.routes import api as base_api from api.routes import routes from api.swaggerui.namespaces.api_doc_namespace import api as api_namespace def create_app(): app = Flask(__name__, static_folder='/tmp/templates', template_folder='/tmp/templates') app = Flask(__name__, static_folder='/tmp/templates', template_folder='/tmp/api/templates') app.config['TEMPLATES_AUTO_RELOAD'] = True app.register_blueprint(base_api.blueprint, url_prefix='/') app.register_blueprint(routes.blueprint, url_prefix='/') api = Api(app, version='1.0', title='Web APIs', description='SWAGGERUI Documentation for web APIs', doc='/doc/') api.add_namespace(api_namespace) Loading
examples/flask_example/api/swaggerui/namespaces/api_doc_namespace.py +4 −3 Original line number Diff line number Diff line from flask_restx import Namespace, Resource import flask_restx from routes import api as api_routes from api.routes import routes import flask from flask import request api = Namespace('api', 'Loads Hello World') @api.route("/") @api.doc() class GetBaseRoute(Resource): def get(self): return api_routes.home() return routes.home() # TODO # Make swagger from flask-restx Loading
examples/flask_example/api/templates/sample_page.html +28 −27 Original line number Diff line number Diff line <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Fetch and Display Text</title> <script> async function fetchAndDisplay(url, targetId) { try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } const text = await response.text(); document.getElementById(targetId).textContent = text; } catch (error) { document.getElementById(targetId).textContent = `Error: ${error.message}`; } } </script> </head> <body> <h1>Fetch and Display Text</h1> <title>Sample Page</title> <link rel= "stylesheet" href="{{ url_for('static', filename='styles/base.css') }}"> <!-- Button for "/" --> <button onclick="fetchAndDisplay('http://localhost:8420/', 'output-home')">Healthcheck</button> <div id="output-home" style="margin-top: 10px; color: blue;"></div> <!-- Button for "/api" --> <button onclick="fetchAndDisplay('http://localhost:8420/api', 'output-api')">Home</button> <div id="output-api" style="margin-top: 10px; color: green;"></div> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <main> <section id="login-card"> <img id="doe-logo" src="{{ url_for('static', filename='images/doeLogo.d97bf559.png') }}" width="123" alt="DOE Logo" title="DOE Logo" /> <span id="login-title__wrapper"> <h1 id="login-title">Sample Page</h1> <img id="login-title__icon" src="{{ url_for('static', filename='images/padlock.svg') }}" alt="padlock icon" title="Padlock icon" /> </span> {% block content %} <a href="/api/test" class="btn btn-primary">Login</a> {% endblock %} </section> </main> </body> </html>
examples/flask_example/docker-compose.override.yml +2 −2 Original line number Diff line number Diff line Loading @@ -19,5 +19,5 @@ services: - FAST_REFRESH=false - FLASK_HOST=http://localhost:9090 volumes: - ./web:/tmp - ./web/scripts:/tmp/scripts - ./scripts:/tmp/scripts - ./api:/tmp/api