2024-10-21 07:55:17 -07:00
|
|
|
# appname/views.py
|
|
|
|
from django.shortcuts import render
|
|
|
|
from django.http import HttpResponse
|
2024-11-12 02:07:36 -08:00
|
|
|
from django.template.defaultfilters import title
|
|
|
|
from django.utils.termcolors import RESET
|
|
|
|
|
|
|
|
from .models import *
|
2024-10-21 07:55:17 -07:00
|
|
|
from . import gemini
|
|
|
|
import markdown
|
|
|
|
|
|
|
|
def home(request):
|
|
|
|
if request.method == 'POST':
|
|
|
|
response = gemini.chat_session.send_message(request.POST['input']).text
|
|
|
|
md = markdown.Markdown()
|
|
|
|
response = md.convert(response)
|
|
|
|
|
|
|
|
form = Statement()
|
2024-11-12 02:07:36 -08:00
|
|
|
reset_button = Reset()
|
2024-10-21 07:55:17 -07:00
|
|
|
return render(request, 'home.html', {'form': form, 'response': response})
|
|
|
|
else:
|
|
|
|
form = Statement()
|
2024-11-12 02:07:36 -08:00
|
|
|
return render(request, 'home.html', {'form': form, 'title': 'Enter data', 'response': 'Enter some basic data to begin:'})
|
2024-10-21 07:55:17 -07:00
|
|
|
|
|
|
|
def about(request):
|
|
|
|
return HttpResponse("This is the about page")
|
|
|
|
|
|
|
|
# def statement(request):
|
|
|
|
# form = Statement()
|
|
|
|
# return render(request, 'home.html', {'form': form})
|