serve static files in deployment on pythonanywhere

31 views
Skip to first unread message

Manuele Pesenti

unread,
Dec 6, 2017, 4:37:20 AM12/6/17
to web2py-users
Hi!

I'm trying to setup static files mapping for my application loaded on
pythonanywhere service.
I followed what indicated in the web configuration panel setting up two
static configuration considering that my application is accessible both
as init and as <appname>.

In order to be sure the configuration takes effect I used a broken path
for one of the two configuration as follows:

1. '/init/static/'             ->    '/home/<my
user>/web2py/applications/<appname>/static/'
2. '/init/<appname>/' ->    '/home/<my
user>/web2py/applications/<appname>/static_broken/'

than (after reloaded the application) I tried to access the same static
file from the browser using the two options:

1. http://<myhostname>/init/static/<pathTo>/<someFile>.js
2. http://<myhostname>/<appname>/static/<pathTo>/<someFile>.js

but (even after reloading file using ctrl+F5) I get the same correct result.

Is there some other configuration or changes to be made on the web2py
side to be made for thees porpuses?

Thanks a lot.

    Manuele

Anthony

unread,
Dec 6, 2017, 9:36:11 AM12/6/17
to web2py-users
I followed what indicated in the web configuration panel setting up two
static configuration considering that my application is accessible both
as init and as <appname>.

First, what do you mean by this -- do you have two exact copies of the same application, one in /applications/init and one in /applications/appname? If so, why?
 
In order to be sure the configuration takes effect I used a broken path
for one of the two configuration as follows:

1. '/init/static/'             ->    '/home/<my
user>/web2py/applications/<appname>/static/'
2. '/init/<appname>/' ->    '/home/<my
user>/web2py/applications/<appname>/static_broken/'

web2py will not generate any URLs matching /init/<appname> to point to static files (or for any requests). What is the point of that mapping?
 

than (after reloaded the application) I tried to access the same static
file from the browser using the two options:

1. http://<myhostname>/init/static/<pathTo>/<someFile>.js
2. http://<myhostname>/<appname>/static/<pathTo>/<someFile>.js

Mapping #2 above is for /init/<appname>, so it will not affect requests to /<appname>/static. If you want to re-route requests for /<appname>/static, then you need a mapping for that pattern.

What exactly are you trying to achieve? Why are you trying to map some static requests to a non-existent folder?

Anthony

Manuele Pesenti

unread,
Dec 6, 2017, 10:19:12 AM12/6/17
to web...@googlegroups.com

Hi Anthony,

thank you for your reply,


On 06/12/2017 15:36, Anthony wrote:
I followed what indicated in the web configuration panel setting up two
static configuration considering that my application is accessible both
as init and as <appname>.

First, what do you mean by this -- do you have two exact copies of the same application, one in /applications/init and one in /applications/appname? If so, why?

I simply create a local symlink in the application folder called init that point to the parallel application folder in order to let the web server respond to the requests with no specified application with the one I want.


 
In order to be sure the configuration takes effect I used a broken path
for one of the two configuration as follows:

1. '/init/static/'             ->    '/home/<my
user>/web2py/applications/<appname>/static/'
2. '/init/<appname>/' ->    '/home/<my
user>/web2py/applications/<appname>/static_broken/'

errata corrige:

2. '/<appname>/static/' ->    '/home/<my user>/web2py/applications/<appname>/static_broken/'


web2py will not generate any URLs matching /init/<appname> to point to static files (or for any requests). What is the point of that mapping?

as far as I can see in the headers of my web application pages static files are linked accordingly to the requested path, so:

if http://myhost/app/default is requested static file links looks like: http://myhost/app/static/...
on the other hand if http://myhost/init/default is requested static file links looks like: http://myhost/init/static/...

isn't it correct??


 

than (after reloaded the application) I tried to access the same static
file from the browser using the two options:

1. http://<myhostname>/init/static/<pathTo>/<someFile>.js
2. http://<myhostname>/<appname>/static/<pathTo>/<someFile>.js

Mapping #2 above is for /init/<appname>, so it will not affect requests to /<appname>/static. If you want to re-route requests for /<appname>/static, then you need a mapping for that pattern.

you're right... I wrote an errata corrige for that above. Sorry.



What exactly are you trying to achieve? Why are you trying to map some static requests to a non-existent folder?

I just wanted to check the effect of my configuration.


Anthony
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony

unread,
Dec 6, 2017, 11:13:29 AM12/6/17
to web2py-users
On Wednesday, December 6, 2017 at 10:19:12 AM UTC-5, Manuele wrote:

Hi Anthony,

thank you for your reply,


On 06/12/2017 15:36, Anthony wrote:
I followed what indicated in the web configuration panel setting up two
static configuration considering that my application is accessible both
as init and as <appname>.

First, what do you mean by this -- do you have two exact copies of the same application, one in /applications/init and one in /applications/appname? If so, why?

I simply create a local symlink in the application folder called init that point to the parallel application folder in order to let the web server respond to the requests with no specified application with the one I want.

A better approach is to use the parameter-based rewrite system to make your app the default application (that way, you will never see /init in the URL).
 
web2py will not generate any URLs matching /init/<appname> to point to static files (or for any requests). What is the point of that mapping?

as far as I can see in the headers of my web application pages static files are linked accordingly to the requested path, so:

if http://myhost/app/default is requested static file links looks like: http://myhost/app/static/...
on the other hand if http://myhost/init/default is requested static file links looks like: http://myhost/init/static/...

isn't it correct??

Yes, correct. My comment was in reference to your /init/<appname> URL, which apparently was just a mistake.
 

 

than (after reloaded the application) I tried to access the same static
file from the browser using the two options:

1. http://<myhostname>/init/static/<pathTo>/<someFile>.js
2. http://<myhostname>/<appname>/static/<pathTo>/<someFile>.js

Mapping #2 above is for /init/<appname>, so it will not affect requests to /<appname>/static. If you want to re-route requests for /<appname>/static, then you need a mapping for that pattern.

you're right... I wrote an errata corrige for that above. Sorry.


What exactly are you trying to achieve? Why are you trying to map some static requests to a non-existent folder?

I just wanted to check the effect of my configuration.

Maybe the browser has cached the files -- try a force refresh. Otherwise, check with Pythonanywhere support.

Anthony
Reply all
Reply to author
Forward
0 new messages