Commit b3924a78 authored by Nane Kratzke's avatar Nane Kratzke
Browse files

Aktualisieren .gitlab-ci.yml, prime/rest.py, prime/Dockerfile, prime/requirements.txt Dateien

parent b7c27a0b
variables:
KUBECTL: "bitnami/kubectl:1.18.9"
image:
name: $KUBECTL
entrypoint: [""]
stages:
- build
- deploy
container:
stage: build
services:
- docker:dind
only:
changes:
- prime/*
- prime/*/*
- .gitlab-ci.yml
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- cd prime
- docker build -t $CI_REGISTRY_IMAGE:$VERSION -t $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:$VERSION
- docker push $CI_REGISTRY_IMAGE:latest
FROM python:3.8-alpine
COPY . /app/
WORKDIR /app
RUN apk update && apk upgrade && apk add --no-cache bash git openssh
RUN pip3 install -r requirements.txt
ENTRYPOINT ["python3", "rest.py"]
Flask>=1.1, <1.2
from flask import Flask, render_template, request, jsonify, abort, redirect
import os
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
log = logging.getLogger(name)
app = Flask(__name__, static_url_path="/static", template_folder="templates")
@app.route("/is_prime/<number>")
def is_prime(number):
try:
n = int(number)
for i in range(2, n):
if n % i == 0:
return f"{ number } is not a prime number. It can be divided by { i }"
return f"{ number } is a prime number"
except Exception ex:
abort(400, f"{ number } is not a number")
url = request.args.get('url')
if url:
return render_template('index.html',
filesurl = f"/git?url={url}",
name = "Codepad",
author = "N. Kratzke"
)
log.info("Starting codepad")
app.run(host='0.0.0.0', port=80)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment