简体   繁体   中英

Recompile Python code on Raspberry Pi?

I know might sound like a dummy question but I'd know if a Python code needs to be recompiled or that's done (binding / rendering) by the server that handles Python code?

I'm asking you because I've started with a sample project and while adding link to a page I got a "Page not found" (404 error)

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.

and Python code looks like:

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)),
)

Try changing url(r'^/mypage.html', 'httpi.views.index'), to url(r'^mypage.html/$', 'httpi.views.index'), .

The regex looks like it has an additional starting slash and I would guess that's what's throwing it off. The error message says it does not recognize the url you typed in and helpfully points out that you could probably get a valid response at one of the other specified urls. Alternatively, according to the routing you showed here, if you typed in no page beyond your base server url (likely http://localhost:8000/ ), it would take you to the same view as the one specified at mypage.html.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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