I want any "file not found" 404 error arising in the folder /Codebox to be applied by error_handlers at the bottom of the code. Since the code is read from top and all handlers have to come above the error_handlers, I want to modify the code of the handlers so that they exclude the contents of the folder /Codebox and so that any error arising from this folder will be taken care by the error_handlers.
Please suggest a regexpression to exclude the contents of a single named folder. Thank you.
Is this code Java? This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia! Ask a mod to move this thread to the right forum.
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Is this code Java? This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia! Ask a mod to move this thread to the right forum.
Java?! It's actually YAML; but this is, more specifically, a (Python) server-configuration file.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Last edited by AndrewGSW; 12-09-2012 at 04:20 PM..
@julien that is not working and you are right since it is not javascript regex.
@Phillip Thanks, I am aware of the old saying "as car is to carpet, java is to javascript". I just could not find a forum matching its language...
@Andy You are right, this is a python server configuration file... I was wrong in thinking the regex would be similar to javascript.. I have found the documentation here http://docs.python.org/2/library/re.html but I am still not able to make out a code which will let the errors arising in a specific folder to be handled by error_hander... All I want the code to be is to exclude folder /Codebox and its contents in the expressions used in the top part of the code which are handled by handlers
would redirect (as I understand..) requests to this subfolder to a Python script named yourscript.py, which you would need to create. Reference I'm looking at.
Code:
error_handlers:
- file: default_error.html
.. would redirect any 404 (or other) errors to the page default_error.html. You might redirect to a .py or .php (but I assume Python is your server-side language?). The page that is redirected to could contain a script to provide different content according to the page requested.
But this is the extent of my understanding.. and I may be wrong
Added If you are looking to exclude a folder then 007julien has provided an example using a negative lookahead assertion. That is to say, "does not have this text". I do not know either, whether such a construct is acceptable within your configuration file.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Last edited by AndrewGSW; 12-09-2012 at 06:27 PM..
@Andy the script you suggested would work if I were having a python script (ex: errorhandling.py ) But I am not having any knowledge of python and so I would give up to adopt any alternative.
If only I could make sure non of the regex in the handlers referred to the particular folder /Codebox then I could assign error_handlers:
- file: default_error.html as suggested here https://developers.google.com/appeng...rror_Responses
What do you want it to do when someone visits /Codebox ?
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
If someone goes to /Codebox/xyz.html then it should show them the page but ANY other address combination inside the Codebox directory such as /Codebox/superman.html should take him to a predefined 404.html page in located in the root directory. Do you think it is possible in the configuration file ?
Until you find a proper solution you could perhaps add this code to your default 404 page so that it redirects to your alternative 404:
Code:
if (document.referrer.indexOf('Codebox') + 1) {
location.href = "/someother404.html";
}
I do not know if your requirement is possible in the configuration file - never seen it before today
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Last edited by AndrewGSW; 12-10-2012 at 12:50 AM..
I dont have the default 404page with me either... the 404 error is just a system generated cluttered python data ! I dont know editing the main.py file either... May be we should consider for an alternative...
I dont have the default 404page with me either... the 404 error is just a system generated cluttered python data ! I dont know editing the main.py file either... May be we should consider for an alternative...
Can you not create your own 404 page? That is the whole idea after all..
I wouldn't know if main.py is a general page over which you have no control, or whether you are allowed to create or modify your own version of this (it may not even exist!?).
If you are able to track down your copy of this file (on your server's domain somewhere I assume) then I could have a gander at it. But I suspect that creating your own 404 page is the way to go.
[I thought "lookahead negative assertion" was quite witty, in a reciprocal way?! Maybe its just me ]
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Last edited by AndrewGSW; 12-10-2012 at 01:18 AM..
and it sits in the root and is editable very well.. Please take a look, I am sure this is the key to our solution...
the filestructure is
Webroot
-index.html (my static homepage)
-gate.html (the static pop up )
-app.yaml
-index.yaml
-main.py
-...
-Codebox
--xyz.html (refered to as treasure)
The main.py code
Code:
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template
class MainHandler(webapp.RequestHandler):
def get (self, q):
if q is None:
q = 'index.html'
path = os.path.join (os.path.dirname (__file__), q)
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))
def main ():
application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
util.run_wsgi_app (application)
if __name__ == '__main__':
main ()