404 not found http://localhost:6543/plain

129 views
Skip to first unread message

Rado Duoistin

unread,
Oct 28, 2016, 3:21:39 AM10/28/16
to pylons-discuss
Hi all. I apologize for a simple question.


I'm doing a lesson

Why am I getting a 404 error when calling http://0.0.0.0:6543/plain.

My __init__.py
from pyramid.config import Configurator


def main(global_config, **settings):
    config = Configurator(settings=settings)
    config.add_route('home', '/')
    config.add_route('plain', '/plain')
    config.scan('.views')
    return config.make_wsgi_app()


My views.py
from pyramid.httpexceptions import HTTPFound
from pyramid.response import Response
from pyramid.view import view_config




class TutorialViews:
   
def __init__(self, request):
       
self.request = request


   
@view_config(route_name='home')
   
def home(self):
       
return HTTPFound(location='/plain')


   
@view_config(route_name='plain')
   
def plain(self):
        name
= self.request.params.get('name', 'No Name Provided')


        body
= 'URL %s with name: %s' % (self.request.url, name)
       
return Response(
            content_type
='text/plain',
            body
=body
       
)

I have config.add_route('plain', '/plain') and return HTTPFound(location='/plain'), but 404 not found ((( 

Where did I go wrong?

Steve Piercy

unread,
Oct 28, 2016, 3:37:42 AM10/28/16
to pylons-...@googlegroups.com
What's your console output?

What's the exact error message?

Did you include a trailing "."? You should not.

I cannot replicate the issue without further information.

--steve


On 10/28/16 at 12:01 AM, radomir...@gmail.com (Rado Duoistin) pronounced:

> Hi all. I apologize for a simple question.
>
>
> I'm doing a lesson
> http://docs.pylonsproject.org/projects/pyramid/en/latest/quick_tutorial/request_response.
> htm
> <http://docs.pylonsproject.org/projects/pyramid/en/latest/quick_tutorial/request_response.
> html>
>
> Why am I getting a 404 error when calling http://0.0.0.0:6543/plain.
>
> My *__init__.py*
> from pyramid.config import Configurator
>
>
> def main(global_config, **settings):
> config = Configurator(settings=settings)
> config.add_route('home', '/')
> config.add_route('plain', '/plain')
> config.scan('.views')
> return config.make_wsgi_app()
>
>
> My *views.py*
> from pyramid.httpexceptions import HTTPFound
> from pyramid.response import Response
> from pyramid.view import view_config
>
>
>
>
> class TutorialViews:
> def __init__(self, request):
> self.request = request
>
>
> @view_config(route_name='home')
> def home(self):
> return HTTPFound(location='/plain')
>
>
> @view_config(route_name='plain')
> def plain(self):
> name = self.request.params.get('name', 'No Name Provided')
>
>
> body = 'URL %s with name: %s' % (self.request.url, name)
> return Response(
> content_type='text/plain',
> body=body
> )
>
> I have config.add_route('plain', '/plain') and return HTTPFound(location=
> '/plain'), but 404 not found (((
>
> Where did I go wrong?
>

------------------------
Steve Piercy, Soquel, CA

Rado Duoistin

unread,
Oct 28, 2016, 4:11:05 AM10/28/16
to pylons-discuss
Sorry.
My console output. 

Starting subprocess with file monitor
Starting server in PID 6804.
Starting HTTP server on http://0.0.0.0:6543
127.0.0.1 - - [28/Oct/2016 10:58:55] "GET / HTTP/1.1" 200 521
127.0.0.1 - - [28/Oct/2016 10:59:02] "GET /plain HTTP/1.1" 404 542

Error mesage.

404 Not FoundThe resource could not be found.

/plain.

Where should I include a trailing "." ?



пятница, 28 октября 2016 г., 10:37:42 UTC+3 пользователь Steve Piercy написал:
What's your console output?

What's the exact error message?

Did you include a trailing "."?  You should not.

I cannot replicate the issue without further information.

--steve




Steve Piercy

unread,
Oct 28, 2016, 4:35:44 AM10/28/16
to pylons-...@googlegroups.com
You should not include a trailing "." in the URL.

Here's my console for comparison:

Starting server in PID 67282.
Starting HTTP server on http://0.0.0.0:6543
127.0.0.1 - - [28/Oct/2016 00:35:01] "GET / HTTP/1.1" 302 548
127.0.0.1 - - [28/Oct/2016 00:35:01] "GET /plain HTTP/1.1" 200 57

Note that you should have a 302 redirect from `/` to the 200 `/plain`.

I think you are in the wrong directory when invoking `pserve development.ini --reload`.

Did you omit any sub-step within this step?

Did you run the tests first?

Did you follow all the steps in the entire Quick Tutorial in sequence, or jump right to this step?

Finally, compare your source files against ours:
https://github.com/Pylons/pyramid/tree/1.7-branch/docs/quick_tutorial/request_response

--steve


On 10/28/16 at 1:11 AM, radomir...@gmail.com (Rado Duoistin) pronounced:

Rado Duoistin

unread,
Oct 28, 2016, 5:53:43 AM10/28/16
to pylons-discuss
Thanks for the reply


Starting server in PID 67282.
Starting HTTP server on http://0.0.0.0:6543
127.0.0.1 - - [28/Oct/2016 00:35:01] "GET / HTTP/1.1" 302 548
127.0.0.1 - - [28/Oct/2016 00:35:01] "GET /plain HTTP/1.1" 200 57

Note that you should have a 302 redirect from `/` to the 200 `/plain`.
 
Shouldn't  I have 200?
 

I think you are in the wrong directory when invoking `pserve development.ini --reload`.

My directory and start command 
~/projects/quick_tutorial/request_response$ $VENV/bin/pserve development.ini --reload

 
Did you omit any sub-step within this step?

I do step by step, starting from the first lesson

Did you run the tests first?

Yes! I run tests.
Result

~/projects/quick_tutorial/request_response$ $VENV/bin/py.test tutorial/tests.py -q.....
5 passed in 0.39 seconds
 
Did you follow all the steps in the entire Quick Tutorial in sequence, or jump right to this step?

Yes! Lesson by lesson.
 I compared with git.
 I have a directory tutorial.egg-info and directory tutorial/__pycache__, also file tutorial/home.pt


 


Steve Piercy

unread,
Oct 28, 2016, 6:09:29 AM10/28/16
to pylons-...@googlegroups.com
On 10/28/16 at 2:53 AM, radomir...@gmail.com (Rado Duoistin) pronounced:

> > Starting server in PID 67282.
> > Starting HTTP server on http://0.0.0.0:6543
> > 127.0.0.1 - - [28/Oct/2016 00:35:01] "GET / HTTP/1.1" 302 548
> > 127.0.0.1 - - [28/Oct/2016 00:35:01] "GET /plain HTTP/1.1" 200 57
> >
> > Note that you should have a 302 redirect from `/` to the 200 `/plain`.
> >
>
> Shouldn't I have 200?

For `/plain`, yes. For `/`, it should be a 302 redirect, which takes you to `/plain`.

> Finally, compare your source files against ours:
> >
> > https://github.com/Pylons/pyramid/tree/1.7-branch/docs/quick_tutorial/request_response
> >
>
> I compared with git.
> I have a directory tutorial.egg-info and directory tutorial/__pycache__,
> also file tutorial/home.pt

The egg is normal and the result of doing `pip install -e .`.

I don't have a `tutorial/home.pt`. Delete that file.

I don't have a pycache. Delete that file, then try restarting pserve.

Rado Duoistin

unread,
Oct 29, 2016, 8:26:54 AM10/29/16
to pylons-discuss
Hm...

Delete home.pt, delete pycache. Restarting pserve.

But 302 is not working.

~/projects/quick_tutorial/request_response$ $VENV/bin/pserve development.ini --reload
Starting subprocess with file monitor
Starting server in PID 15093.
Starting HTTP server on http://0.0.0.0:6543
127.0.0.1 - - [29/Oct/2016 13:10:45] "GET /plain HTTP/1.1" 404 546
127.0.0.1 - - [29/Oct/2016 13:10:49] "GET / HTTP/1.1" 200 525

пятница, 28 октября 2016 г., 13:09:29 UTC+3 пользователь Steve Piercy написал:

Steve Piercy

unread,
Oct 29, 2016, 8:45:58 AM10/29/16
to pylons-...@googlegroups.com
Maybe there is some subtle difference between your source and
ours that is not obvious?

Archive your source code, and put it somewhere to download and
share the link.

I'd also suggest deleting your source, and using the source from:
https://github.com/Pylons/pyramid/tree/1.7-branch/docs/quick_tutorial/request_response

Here's my `pip freeze` for comparison.

$ bin/pip freeze
Mako==1.0.4
MarkupSafe==0.23
PasteDeploy==1.5.2
Pygments==2.1.3
pyramid==1.7.3
pyramid-debugtoolbar==3.0.4
pyramid-mako==1.0.2
repoze.lru==0.6
translationstring==1.3
-e git+https://github.com/Pylons/pyramid.git@2414d270c56b06d60b16cd38967559c5a47766b7#egg=tutorial&subdirectory=qtut/request_response
venusian==1.0
WebOb==1.6.2
zope.deprecation==4.1.2
zope.interface==4.3.2

And you've already run the tests, which passed, exactly like in
the docs for this tutorial step.

I'm at a total loss as to why your source code won't redirect
like mine, so I'm just tossing up random things at this point.
I hope someone smarter than I can help. :/

--steve


On 10/29/16 at 5:26 AM, radomir...@gmail.com (Rado
Duoistin) pronounced:

>Hm...
>
>Delete home.pt, delete pycache. Restarting pserve.
>
>But 302 is not working.
>
>~/projects/quick_tutorial/request_response$ $VENV/bin/pserve
>development.ini --reload
>Starting subprocess with file monitor
>Starting server in PID 15093.
>Starting HTTP server on http://0.0.0.0:6543
>127.0.0.1 - - [29/Oct/2016 13:10:45] "GET /plain HTTP/1.1" 404 546
>127.0.0.1 - - [29/Oct/2016 13:10:49] "GET / HTTP/1.1" 200 525
>
>пятница, 28 октября 2016 г., 13:09:29 UTC+3
>пользователь Steve Piercy написал:
>>
>>On 10/28/16 at 2:53 AM, radomir...@gmail.com <javascript:>

Rado Duoistin

unread,
Nov 3, 2016, 2:21:51 PM11/3/16
to pylons-discuss
Thanks! Steve! :)

суббота, 29 октября 2016 г., 15:45:58 UTC+3 пользователь Steve Piercy написал:
Reply all
Reply to author
Forward
0 new messages