python - Adding falcon application routes on a root directory -


i writing falcon application serving webpages. have js, css files under /js, /css under root dir. these /js , /css directories can have multiple subdirectories , files may located inside 1 of sub directories.

i want have falcon apps route added such webpage requests

/js/subdir1/subdir2/temp.js /js/subdir1/temp2.js  

can satisfied same responder method.

but when tried, having route added like

app.add_route("/js/{filename}", resourceclass()) 

the request /js/subdir1/subdir2/temp.js not reach responder.

the responder have below,

class resourceclass(object):     def on_get(self, request, response, filename):         file_path = os.path.join(path_to_js,filename)         serve_file(response, file_path) 

serve_file create appropriate response , return it.

i want filename populated

"subdir1/subdir2/temp.js" "/js/subdir1/subdir2/temp.js" , "subdir1/temp2.js" "/js/subdir1/temp2.js " 

how can add route , add responder ?

if you're using apache can configure site below:

alias /js/ /path/to/wsgi/js/  <directory /path/to/wsgi/js>     order deny,allow     allow </directory>  wsgiscriptalias / /path/to/wsgi/script.py  <directory /path/to/wsgi>     <files script.py>         order allow,deny         allow     </files> </directory> 

restart apache , under http://localhost/js url should reach static files


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -