Ejemplo n.º 1
0
def home(request):
    if request.method == 'POST':
        form = DockerfileRequestForm(request.POST)
        if form.is_valid():
            template = loader.get_template("docker/centos6.dockerfile")
            dd = template.render(Context(form.cleaned_data))
            return render(request, "dockerfile.html", {'dockerfile': dd})
    else:
        form = DockerfileRequestForm()

    return render(request, "index.html", {'form': form})
Ejemplo n.º 2
0
def generate(request):
    form = DockerfileRequestForm(request.GET)
    if form.is_valid():
        os = form.cleaned_data["os"]
        try:
            template = loader.get_template("docker/{}.dockerfile".format(os))
        except TemplateDoesNotExist:
            raise Http404('Template for "{}" does not exists'.format(os))
        dd = template.render(Context(form.cleaned_data))
        return render(request, "dockerfile.html", {"dockerfile": dd})
    else:
        return render(request, "index.html", {'form': form})