librelist archives

« back to archive

Problem with path deploying in URL different from /

Problem with path deploying in URL different from /

From:
Alex
Date:
2011-06-05 @ 21:17
Hi all.

I have created a simple application (as a python package) using the
following layout

macroman/
├── pages
├── static
│   ├── css
│   │   └── blueprint
│   ├── img
│   └── js
└── templates

On my machine with the development server all is OK.
When I deploy the application under the path:

subdomain.example.org/myprefix

I can access the application root page, but all the URL  generated by
`url_for()` are missing the prefix 'myprefix'.
I have read http://flask.pocoo.org/snippets/35/ and the relevant
messages in the mailing list archive but I did not fully understood if
the provided solution apply to my issue and if there is something
easier I can do.
My production server is Apache2 + mod_wsgi on Webfaction

Thank you.
Alex

Re: [flask] Problem with path deploying in URL different from /

From:
JimG
Date:
2011-06-06 @ 10:28
What does it say in the apache log?

On 5 June 2011 22:17, Alex <thinkpragmatic@gmail.com> wrote:

> Hi all.
>
> I have created a simple application (as a python package) using the
> following layout
>
> macroman/
> ├── pages
> ├── static
> │   ├── css
> │   │   └── blueprint
> │   ├── img
> │   └── js
> └── templates
>
> On my machine with the development server all is OK.
> When I deploy the application under the path:
>
> subdomain.example.org/myprefix
>
> I can access the application root page, but all the URL  generated by
> `url_for()` are missing the prefix 'myprefix'.
> I have read http://flask.pocoo.org/snippets/35/ and the relevant
> messages in the mailing list archive but I did not fully understood if
> the provided solution apply to my issue and if there is something
> easier I can do.
> My production server is Apache2 + mod_wsgi on Webfaction
>
> Thank you.
> Alex
>

Re: [flask] Problem with path deploying in URL different from /

From:
Alex
Date:
2011-06-06 @ 11:35
Both access log and error log don't say anything about wrong URLs
maybe because I'm serving static files via Flask (it's a small app
with just a few static files). Now I fixed the problem  adding a
variable

PREFIX = 'myprefix'

in the configuration object and prepending config.PREFIX each time
url_for is called in the template or in the views. This seems to me
quite stupid but I couldn't find a better solution right now. A better
approach maybe could be wrapping url_for in another function that
simply add the prefix and use that function instead of url_for. Is
this a valid alternative solution? Could anyone give an advice about
how to implement it?

Thanks.

Alex

On Mon, Jun 6, 2011 at 12:28 PM, JimG <j.gumbley@gmail.com> wrote:
> What does it say in the apache log?
>
> On 5 June 2011 22:17, Alex <thinkpragmatic@gmail.com> wrote:
>>
>> Hi all.
>>
>> I have created a simple application (as a python package) using the
>> following layout
>>
>> macroman/
>> ├── pages
>> ├── static
>> │   ├── css
>> │   │   └── blueprint
>> │   ├── img
>> │   └── js
>> └── templates
>>
>> On my machine with the development server all is OK.
>> When I deploy the application under the path:
>>
>> subdomain.example.org/myprefix
>>
>> I can access the application root page, but all the URL  generated by
>> `url_for()` are missing the prefix 'myprefix'.
>> I have read http://flask.pocoo.org/snippets/35/ and the relevant
>> messages in the mailing list archive but I did not fully understood if
>> the provided solution apply to my issue and if there is something
>> easier I can do.
>> My production server is Apache2 + mod_wsgi on Webfaction
>>
>> Thank you.
>> Alex
>
>