**已关闭。**此问题需要debugging details。当前不接受答案。
编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
2天前关闭。
Improve this question
我用django框架做了一个聊天机器人,我尝试用heroku部署,但它一直显示无法部署,如果我转到http://127.0.0.1:8000/chatbot/,我的应用程序在本地工作正常,但如果我设置主页http://127.0.0.1:8000/,Heroku可能会工作,所以我想知道如何更改我的urls.py,将主页设置为http://127.0.0.1:8000/
urls.py
from django.urls import path
from django.views.generic import TemplateView
urlpatterns = [
path('', TemplateView.as_view(template_name='index.html'), name='home'),
]
在模板文件夹中,我有一个名为index.html的html文件
我应该如何更改代码以将主页设置为http://127.0.0.1:8000/
views.py
from django.shortcuts import render
import openai
openai.api_key = API_KEYS
def chatbot(prompt):
response = openai.Completion.create(
model="text-davinci-003",
prompt=prompt,
temperature=0.7,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
return response.choices[0].text.strip()
def chatbot_view(request):
chatbot_response = ""
if request.method == 'POST':
question = request.POST.get('question')
chatbot_response = chatbot(question)
return render(request, 'index.html', {'chatbot_response': chatbot_response})
我想换个urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.chatbot_view),
]
但没有用
2条答案
按热度按时间zc0qhyus1#
我更改了urls.py根目录中的www.example.com
这将我的主页设置为默认页面,但仍然没有修复heroku,但我会尝试找出它
rqcrx0a62#
要将Django应用的主页设置为http://127.0.0.1:8000/,您可以修改urls.py文件。