2013-05-12 75 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中指定的视图相同的视图。