簡體   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