from django.shortcuts import render
from django.http import HttpResponse
import requests

# def index(request):
#     return "Hello, world. You're at the polls index."

def home_view(request, *args, **kwargs):
    # return HttpResponse("<h1> hello world </h1>")
    return render(request, "index.html", {})

def contact_view(request, *args, **kwargs):
    return render(request, "contact.html", {})

def data_view(request, *args, **kwargs):
    my_data= {
        "judul": "data yang ada",
        "data" : 12324324,
        "penguji": ["tenov", "mario", "mona"]
    }
    return render(request, "data.html", my_data)

def result_view(request, *args, **kwargs):
    return render(request, "result.html", {})


# def button(request):
#     return render(request,'home.html')



# def output(request):
#     data=requests.get("https://www.google.com/")
#     print(data.text)
#     data=data.text
#     return render(request,'home.html',{'data':data})

from subprocess import run,PIPE
import sys

def button(request):
    return render(request,'home.html')


def output(request):
    data=requests.get("https://www.google.com/")
    print(data.text)
    data=data.text
    return render(request,'home.html',{'data':data})


def external(request):
    inp= request.POST.get('param')
    out= run([sys.executable,'//home//andreas//mysite//Project_STBI.py',inp],shell=False,stdout=PIPE)
    print(out)
    return render(request,'home.html',{'data1':out.stdout})
