在Raspberry Pi上重新编译Python代码?

时间:2013-05-12 23:02:06

标签: python django raspberry-pi

我知道这可能听起来像是一个假问题,但我知道Python代码是否需要重新编译或者由处理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 个答案:

答案 0 :(得分:1)

尝试将url(r'^/mypage.html', 'httpi.views.index'),更改为url(r'^mypage.html/$', 'httpi.views.index'),

正则表达式看起来有一个额外的起始斜线,我猜这就是抛弃它的原因。错误消息表明它无法识别您输入的网址,并有助于指出您可能会在其他指定网址上获得有效响应。或者,根据您在此处显示的路由,如果您在基本服务器网址之外没有输入任何页面(可能是http://localhost:8000/),则会转到与mypage.html中指定的视图相同的视图。