繁体   English   中英

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

[英]Recompile Python code on 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)),
)

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM