這里寫目錄標題
- 一級目錄
- 1. 訪問Django項目,python web url時,報錯
- 2. 傳參報名,python web url時,報錯
- 正確訪問結果:
- 二、購買價格 和 見錯誤碼
一級目錄
1. 訪問Django項目,python web url時,報錯
<div id="explanation"><p>You’re seeing this error because you have <code>DEBUG = True</code> inyour Django settings file. Change that to <code>False</code>, and Djangowill display a standard 404 page.</p></div>
原程序如下 :
from django.urls import pathfrom ltjt_aiseek_app.com.ltjt.web import views# from. import viewsurlpatterns = [# 這里可以添加具體的路由映射,例如:# path('chat/', views.chat, name='chat'),# 不行的話 再把views 放到根目錄下來# 'chat/' 后面帶不帶/ 決定了訪問時 http://localhost:9000/api/chat 的最后要不要 http://localhost:9000/api/chat/path('chat/', views.chat, name='chat'),# path('chat', views.chat, name='chat'),
]
第1次訪問Url 結尾不帶 ”/“
http://localhost:9000/api/chat
第2次訪問Url 結尾不帶 ”/“
http://localhost:9000/api/chat/
帶 ”/" 不方便,選擇修改程序 urls.py,路由映射中去年 “/”
2. 傳參報名,python web url時,報錯
Internal Server Error: /api/chat
Traceback (most recent call last):File "D:\Users\wang\IdeaProjects\ltkj_git\ltjt-ai-seek\seek_backend_py\ltjt_aiseek_app\com\ltjt\web\views.py", line 37, in chattongyi_response = tongyi_llm.chat(messages)File "D:\Users\wang\IdeaProjects\ltkj_git\ltjt-ai-seek\seek_backend_py\ltjt_aiseek_app\com\ltjt\models\tongyiqianwen.py", line 24, in chat"role": msg["role"],
TypeError: string indices must be integers
During handling of the above exception, another exception occurred:
messages = [{"role": "user","content": "介紹一下故宮"}]
正確訪問結果:
哪些是有用的值,哪些需要保存