Hi Everybody,
I have a problem with "url_for()" function.
My sources like this:
file.html:
...
<a href="{{ url_for(notefile.route) }}" >a link</a>
...
file.py
@notefile.route('/file')
...
...
@notefile.route('/file/comment'):
...
...
now i visit the url 'www.xxx.com/file' and get the file.html.
then i click 'a link'.
When i run this step with the development environment on my PC, it is all
OK. i jump to 'www.xxx.com/file/comment'.
But when i run it on VPS, i jump to
'www.xxx.com/file/file/comment'.It<http://www.xxx.com/file/file/comment%27.It>appends
'/file/comment' to '
www.xxx.com/file'.
how to fix this problem?
thanks.
--
--
Best Regards,
Ranler
--
url_for() first argument endpoint should be the url handle function name, not decorator name. On Fri, Jun 10, 2011 at 7:53 AM, Ranler Cao <findfunaax@gmail.com> wrote: > Hi Everybody, > > I have a problem with "url_for()" function. > > My sources like this: > > file.html: > ... > <a href="{{ url_for(notefile.route) }}" >a link</a> > ... > > file.py > @notefile.route('/file') > ... > > ... > @notefile.route('/file/comment'): > ... > ... > > > > now i visit the url 'www.xxx.com/file' and get the file.html. > then i click 'a link'. > > When i run this step with the development environment on my PC, it is all > OK. i jump to 'www.xxx.com/file/comment'. > But when i run it on VPS, i jump to 'www.xxx.com/file/file/comment'.It<http://www.xxx.com/file/file/comment%27.It>appends '/file/comment' to ' > www.xxx.com/file'. > > how to fix this problem? > thanks. > > > -- > -- > > Best Regards, > Ranler > > -- > -- Sent from my Android Dev Phone 1
Sorry, i input it wrong ...
My Source is like this,
file.html:
...
<a href="{{ url_for(notefile.view_comment) }}" >a link</a>
...
file.py
...
@notefile.route('/file')
def view_notefile()
...
render_template('/file.html')
...
@notefile.route('/file/comment'):
def view_comment()
...
And my problem is the same.
2011/6/10 Richard Kong <kong.lingchao@gmail.com>
> decorator
--
--
Best Regards,
Ranler
--
Hi,
Since this is an issue across two installations, could you post the
versions of Flask you are using? If you have distribute/setuptools
installed, you can get the version with:
import pkg_resources
pkg_resources.get_distribution('Flask').version
-Ron
On Fri, Jun 10, 2011 at 2:43 AM, Ranler Cao <findfunaax@gmail.com> wrote:
> Sorry, i input it wrong ...
>
> My Source is like this,
> file.html:
> ...
> <a href="{{ url_for(notefile.view_comment) }}" >a link</a>
> ...
>
> file.py
> ...
> @notefile.route('/file')
> def view_notefile()
> ...
> render_template('/file.html')
> ...
> @notefile.route('/file/comment'):
> def view_comment()
> ...
>
> And my problem is the same.
>
>
>
> 2011/6/10 Richard Kong <kong.lingchao@gmail.com>
>>
>> decorator
>
>
> --
> --
>
> Best Regards,
> Ranler
>
> --
>
The installation that has this problem: debian6 2.6.26-2-xen-686 Python 2.6.6 flask 0.6.1 I have not the other installation at hand ... Should I update flask to the latest version? 2011/6/10 Ron DuPlain <ron.duplain@gmail.com> > Hi, > > Since this is an issue across two installations, could you post the > versions of Flask you are using? If you have distribute/setuptools > installed, you can get the version with: > > import pkg_resources > pkg_resources.get_distribution('Flask').version > > -Ron > > > On Fri, Jun 10, 2011 at 2:43 AM, Ranler Cao <findfunaax@gmail.com> wrote: > > Sorry, i input it wrong ... > > > > My Source is like this, > > file.html: > > ... > > <a href="{{ url_for(notefile.view_comment) }}" >a link</a> > > ... > > > > file.py > > ... > > @notefile.route('/file') > > def view_notefile() > > ... > > render_template('/file.html') > > ... > > @notefile.route('/file/comment'): > > def view_comment() > > ... > > > > And my problem is the same. > > > > > > > > 2011/6/10 Richard Kong <kong.lingchao@gmail.com> > >> > >> decorator > > > > > > -- > > -- > > > > Best Regards, > > Ranler > > > > -- > > > -- -- Best Regards, Ranler --
On Fri, Jun 10, 2011 at 3:47 AM, Ranler Cao <findfunaax@gmail.com> wrote: > The installation that has this problem: > debian6 2.6.26-2-xen-686 > Python 2.6.6 > flask 0.6.1 > > I have not the other installation at hand ... > > Should I update flask to the latest version? I ask, because Modules and endpoints have been changing since the last release (0.6.1) and I wanted to see if there was a problem there. I think this is more likely a problem with your web server configuration in production, in which case you'll have to provide more information. Have you tried running the Flask development server on the production host to verify that Flask itself is working? Or is that what you are doing already? -Ron > 2011/6/10 Ron DuPlain <ron.duplain@gmail.com> >> >> Hi, >> >> Since this is an issue across two installations, could you post the >> versions of Flask you are using? If you have distribute/setuptools >> installed, you can get the version with: >> >> import pkg_resources >> pkg_resources.get_distribution('Flask').version >> >> -Ron >> >> >> On Fri, Jun 10, 2011 at 2:43 AM, Ranler Cao <findfunaax@gmail.com> wrote: >> > Sorry, i input it wrong ... >> > >> > My Source is like this, >> > file.html: >> > ... >> > <a href="{{ url_for(notefile.view_comment) }}" >a link</a> >> > ... >> > >> > file.py >> > ... >> > @notefile.route('/file') >> > def view_notefile() >> > ... >> > render_template('/file.html') >> > ... >> > @notefile.route('/file/comment'): >> > def view_comment() >> > ... >> > >> > And my problem is the same. >> > >> > >> > >> > 2011/6/10 Richard Kong <kong.lingchao@gmail.com> >> >> >> >> decorator >> > >> > >> > -- >> > -- >> > >> > Best Regards, >> > Ranler >> > >> > -- >> > > > > > -- > -- > > Best Regards, > Ranler > > -- >
I run the Flask development server on the production host, and it is no
problem.
Then I check my webserver configure. I use nginx+fastcgi.
I google some problems like this, and as Ron says I lose something in my
configure.
So I fix it .
server {
listen 80;
server_name findfunaax.com;
location / { try_files $uri @myapp; } # Importent!
location @myapp { # Importent!
include fastcgi_params;
fastcgi_param SCRIPT_NAME "";
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass unix:/tmp/myapp.sock;
}
}
Now it's OK.
thanks :-)
2011/6/10 Ron DuPlain <ron.duplain@gmail.com>
> On Fri, Jun 10, 2011 at 3:47 AM, Ranler Cao <findfunaax@gmail.com> wrote:
> > The installation that has this problem:
> > debian6 2.6.26-2-xen-686
> > Python 2.6.6
> > flask 0.6.1
> >
> > I have not the other installation at hand ...
> >
> > Should I update flask to the latest version?
>
> I ask, because Modules and endpoints have been changing since the last
> release (0.6.1) and I wanted to see if there was a problem there.
>
> I think this is more likely a problem with your web server
> configuration in production, in which case you'll have to provide more
> information. Have you tried running the Flask development server on
> the production host to verify that Flask itself is working? Or is
> that what you are doing already?
>
> -Ron
>
>
>
>
> > 2011/6/10 Ron DuPlain <ron.duplain@gmail.com>
> >>
> >> Hi,
> >>
> >> Since this is an issue across two installations, could you post the
> >> versions of Flask you are using? If you have distribute/setuptools
> >> installed, you can get the version with:
> >>
> >> import pkg_resources
> >> pkg_resources.get_distribution('Flask').version
> >>
> >> -Ron
> >>
> >>
> >> On Fri, Jun 10, 2011 at 2:43 AM, Ranler Cao <findfunaax@gmail.com>
> wrote:
> >> > Sorry, i input it wrong ...
> >> >
> >> > My Source is like this,
> >> > file.html:
> >> > ...
> >> > <a href="{{ url_for(notefile.view_comment) }}" >a link</a>
> >> > ...
> >> >
> >> > file.py
> >> > ...
> >> > @notefile.route('/file')
> >> > def view_notefile()
> >> > ...
> >> > render_template('/file.html')
> >> > ...
> >> > @notefile.route('/file/comment'):
> >> > def view_comment()
> >> > ...
> >> >
> >> > And my problem is the same.
> >> >
> >> >
> >> >
> >> > 2011/6/10 Richard Kong <kong.lingchao@gmail.com>
> >> >>
> >> >> decorator
> >> >
> >> >
> >> > --
> >> > --
> >> >
> >> > Best Regards,
> >> > Ranler
> >> >
> >> > --
> >> >
> >
> >
> >
> > --
> > --
> >
> > Best Regards,
> > Ranler
> >
> > --
> >
>
--
--
Best Regards,
Ranler
--