add basic starting prompt

This commit is contained in:
Daniel Cronin 2024-10-22 03:18:37 -05:00
parent 428da090a6
commit 6072c791d5
2 changed files with 33 additions and 1 deletions

View File

@ -18,9 +18,13 @@
<body> <body>
{% if request.method == "POST" %} {% if request.method == "POST" %}
{{ response|safe }} {{ response|safe }}
{% else %}
{{ response|safe }}
{% endif %} {% endif %}
<form action="" method="post"> <form action="" method="post">
{{ form.as_p }} {{ form.as_p }}
<input type="submit" value="Submit"> <input type="submit" value="Submit">

View File

@ -0,0 +1,28 @@
# appname/views.py
from django.shortcuts import render
from django.http import HttpResponse
from .models import Statement
from django.shortcuts import redirect
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)
# formatted_response = re.sub('\*\*', r'\n\n', response)
form = Statement()
return render(request, 'home.html', {'form': form, 'response': response})
else:
form = Statement()
return render(request, 'home.html', {'form': form, 'response': 'Enter some basic data to begin:'})
def about(request):
return HttpResponse("This is the about page")
# def statement(request):
# form = Statement()
# return render(request, 'home.html', {'form': form})