32 lines
772 B
Python
32 lines
772 B
Python
|
from django.shortcuts import render
|
||
|
from django.http import HttpResponse
|
||
|
from .forms import ip
|
||
|
#from .forms import PostForm
|
||
|
from ularegistry.models import ips
|
||
|
from django.shortcuts import redirect
|
||
|
|
||
|
# Create your views here.
|
||
|
def index(request):
|
||
|
if request.method == "POST":
|
||
|
form = ip(request.POST)
|
||
|
print(form)
|
||
|
if form.is_valid():
|
||
|
q = ips(inet=form.cleaned_data['inputIP'])
|
||
|
q.save()
|
||
|
return redirect('index')
|
||
|
|
||
|
else:
|
||
|
form = ip()
|
||
|
|
||
|
ips_list = ips.objects.all()
|
||
|
ctx = { 'form' : form,
|
||
|
'ips_list' : ips_list,
|
||
|
}
|
||
|
return render(request, 'index.html', ctx)
|
||
|
#return HttpResponse("Hello, world.")
|
||
|
|
||
|
|
||
|
def results(request, ips_id):
|
||
|
return HttpResponse(ips_id)
|
||
|
|