2013-05-12 84 views
0

我知道這可能聽起來像一個虛擬問題,但我知道是否需要重新編譯Python代碼,或者是由處理Python代碼的服務器完成(綁定/呈現)?在Raspberry Pi上重新編譯Python代碼?

我問你,因爲我已經開始與一個樣本項目,並同時加入的網頁鏈接我得到了一個「找不到網頁」(404錯誤)

Using the URLconf defined in httpi.urls, Django tried these URL patterns, in this order: 
^$ 
^piface/ 
The current URL, mypage.html, didn't match any of these. 
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. 

和Python代碼如下所示:

from django.conf.urls import patterns, include, url 
from django.conf import settings 

# Uncomment the next two lines to enable the admin: 
# from django.contrib import admin 
# admin.autodiscover() 

urlpatterns = patterns('', 
    url(r'^$', 'httpi.views.index'), 
    url(r'^/mypage.html', 'httpi.views.index'), 
    url(r'^piface/', include('httpiface.urls')), 

    # Uncomment the admin/doc line below to enable admin documentation: 
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), 

    # Uncomment the next line to enable the admin: 
    # url(r'^admin/', include(admin.site.urls)), 
) 

回答

1

嘗試改變url(r'^/mypage.html', 'httpi.views.index'),url(r'^mypage.html/$', 'httpi.views.index'),

該正則表達式看起來像它有一個額外的開始斜槓,我想這是什麼扔掉它。該錯誤消息表示它無法識別您輸入的網址,並有助於指出您可能在其他指定網址之一獲得有效回覆。或者,根據您在此處顯示的路由,如果您在基本服務器URL(可能爲http://localhost:8000/)之外的任何頁面中都沒有輸入任何頁面,則會將您帶入與mypage.html中指定的視圖相同的視圖。