GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - anomaly/lab-python-mock-server: A mock web server in Python for Anomaly labs used to demonstrate that our stack is functional and a web app has access to all the details it needs to function

BranchesTags
Open more actions menu

Latest commit

 

History

35 Commits
35 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
charts
charts
 
 
src
src
 
 
.dockerignore
.dockerignore
 
 
.env.development
.env.development
 
 
.gitignore
.gitignore
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
Taskfile.yml
Taskfile.yml
 
 
docker-compose.yml
docker-compose.yml
 
 

Repository files navigation

Lab - Mock Python server

Docker Pulls

Anomaly uses Python for all of their server side requirements. This lab providers a containerized version of the Python server that mocks the presence of a server and simply outputs a static page with a list of key value pairs that it obtains from the container's environment.

The purpose of this application is to test the fact that the container has access to the secrets passed into it via the Kubernetes secrets mechanism. This application serves as the test Python server for Anomaly's Terraform lab for Linode.

This application should never be used in production.

Configuring the environment variables

The application serves a single root entry point and can be configured in src/lab_mock/__init__.py which has a Python dictionary that resembles

_ENV_LIST = [
    {
        "name": "PostgreSQL",
        "description": "Postgres database credentials",
        "vars": [
            "POSTGRES_USER",
            "POSTGRES_PASSWORD",
            "POSTGRES_HOST",
            "POSTGRES_PORT",
            "POSTGRES_DB",
        ]
    },
]

Each object of the array is contains:

  • name: The name of the environment variable group
  • description: A description of the environment variable group
  • vars: An array of environment variable names that are part of the group

The entry point will fetch the value of each environment variable and output it as a key value pair, outputting None if a value is not found.

Please ensure this list is kept in sync with the Terraform lab, unless of course you are using it for other purposes.

Architecture

The application is built using the Flask framework and uses Jinja2 for templating.

It uses asgiref to create an ASGI wrapper for the Flask application.

To make things look nice, we use Tailwind CSS, delivered via their CDN.

Resources

  • Deploying FastAPI apps with HTTPS powered by Traefik by Sebastián Ramírez
  • How to Inspect a Docker Image’s Content Without Starting a Container by James Walker
  • Poetry sub packages, an open issue to support sub packages in Poetry, which will be handy in splitting up our code base further.
  • Using find namespaces or find namespace package

License

Contents of this repository are licensed under the Apache 2.0 license.

About

A mock web server in Python for Anomaly labs used to demonstrate that our stack is functional and a web app has access to all the details it needs to function

github.com/anomaly/lab-python-mock-server/pkgs/container/lab-python-mock-server

Topics

dockerlearningpythonshowcasetesting

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.