0
0
Flaskframework~20 mins

CI/CD pipeline for Flask - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Flask CI/CD Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of a GitHub Actions workflow step for Flask testing
Given this GitHub Actions step that runs Flask tests, what is the output if all tests pass?
      - name: Run tests
        run: |
          python -m venv venv
          source venv/bin/activate
          pip install -r requirements.txt
          pytest tests/
AAll tests passed successfully with no errors.
BSyntaxError: invalid syntax in requirements.txt
CModuleNotFoundError: No module named 'pytest'
DTests failed with assertion errors.
Attempts:
2 left
💡 Hint
Think about what happens when pytest runs and all tests pass.
Configuration
intermediate
2:00remaining
Correct Dockerfile for a Flask app in CI/CD
Which Dockerfile configuration correctly builds a Flask app image for deployment in a CI/CD pipeline?
A
FROM python:3.12-slim
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
B
FROM node:18
WORKDIR /app
COPY . /app
RUN npm install
CMD ["node", "app.js"]
C
FROM python:3.12
COPY requirements.txt /
RUN pip install -r /requirements.txt
COPY . /app
WORKDIR /app
CMD ["flask", "run"]
D
FROM python:3.12
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
CMD ["flask", "run", "--host=0.0.0.0"]
Attempts:
2 left
💡 Hint
Flask apps need to listen on all interfaces in containers.
🔀 Workflow
advanced
2:00remaining
Order of steps in a CI/CD pipeline for Flask
Arrange these steps in the correct order for a typical CI/CD pipeline for a Flask app:
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,2,1,4
Attempts:
2 left
💡 Hint
Tests must pass before building and pushing images.
Troubleshoot
advanced
2:00remaining
Error when deploying Flask app: "Address already in use"
You deployed your Flask app in a container but get the error: "OSError: [Errno 98] Address already in use". What is the most likely cause?
AThe Dockerfile is missing the requirements.txt file.
BThe Flask app is trying to bind to a port already used by another process.
CThe Flask app code has a syntax error.
DThe container image was not pushed to the registry.
Attempts:
2 left
💡 Hint
This error usually means the port is busy.
Best Practice
expert
2:00remaining
Best practice for secret management in CI/CD for Flask
What is the best practice to handle sensitive environment variables like API keys in a CI/CD pipeline for a Flask app?
AStore secrets directly in the Flask app source code.
BCommit secrets in a separate config file in the repository.
CUse environment variables set securely in the CI/CD platform and inject them at runtime.
DPrint secrets in the CI/CD logs for debugging.
Attempts:
2 left
💡 Hint
Think about security and avoiding exposure of secrets.