Explanation from Stackoverflow: When you use a front slash, you are saying 'take this URL path from root'. But without it, it is in terms of the current location.
This explains why the original code worked when my url was simply localhost:8081/1234 but not in the second scenario where I have a second directory On Wednesday, January 16, 2013 7:44:06 PM UTC-8, NP wrote: > > Finally found the solution (with the help of someone from Stackoverflow) > but now I'm trying to understand the solution. > > In my index.htm file, I load a javascript file using <script > src="include/load.js" type="text/javascript"></script>. > The above worked for urls such as localhost:8081/1234 but fails when the > url is localhost:8081/1234/a-test-case > > I changed it to <script > *src="/include/load.js"*type="text/javascript"></script> i.e. > added a forward slash before the include folder and everything works now. > So now I'm trying to understand why this works. > > My first guess would have been it couldn't find load.js without the extra > forward slash but that doesn't make sense because the Javascript was being > fired correctly without the extra slash (I know this because I use > javascript to control a section of the page. > > On Wednesday, January 16, 2013 6:41:43 PM UTC-8, Julie wrote: >> >> Is it possible that there is indeed a syntax error in your index.html >> template file? >> >> If you check the console output in Chrome >> Tools > Javascript Console > Console >> it should indicate the where the error is. If you click on the error line >> number on the right hand side, the console will show the source code at >> that line. Note that the line number displayed in the console may not be >> the same as the line number in your index.html file, as the template >> variables are filled in. >> >> >> >> On 17 January 2013 13:29, NP <[email protected]> wrote: >> >>> I am running on SDK 1.6.3 and python 2.5 >>> >>> Also, I don't actually use '<' in my url. I only used it in the post >>> here to indicate it is meant to be a placeholder. A real url on my Dev >>> server would be something like localhost:8081/1234/a-simple-example >>> >>> and the error I get from the Firebug console is >>> >>> >>> *- SyntaxError: syntax error* >>> >>> ** >>> >>> *<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//E* >>> >>> If I view the error in Chrome, it says >>> >>> Uncaught SyntaxError: Unexpected token < >>> >>> >>> On Wednesday, January 16, 2013 6:05:10 PM UTC-8, Julie wrote: >>> >>>> NP, can you give an actual example of a URL that you are having >>>> problems with? >>>> Which version of the SDK and Python are you running? >>>> It works for me using App Engine SDK release: "1.7.4" and Python 2.7.3 >>>> >>>> I agree with Jesse that < and > should not be used in a URL, however as >>>> far as I can tell from RFC3986 <http://tools.ietf.org/html/rfc3986>, < >>>> and > are not explicitly reserved characters (however they are also >>>> not included in the unreserved list either). >>>> >>>> Whilst I don't recommend using < or > in a URL, it seems that IE, FF >>>> and Chrome convert those characters to percent-encoded octets before >>>> sending them to the server Within the app, self.request.url shows >>>> those characters as %3C and %3E. >>>> >>>> >>>> On 17 January 2013 07:53, NP <[email protected]> wrote: >>>> >>>>> yea, i only used the anchors (in my post) to signify they are >>>>> placeholders >>>>> >>>>> >>>>> On Wednesday, January 16, 2013 12:04:07 PM UTC-8, Jesse wrote: >>>>>> >>>>>> Since <> are not valid URL characters. >>>>>> >>>>>> On Wednesday, January 16, 2013 2:02:52 PM UTC-6, Jesse wrote: >>>>>>> >>>>>>> You're not actually loading myhost/<post_id>/<**post**_title> >>>>>>> right? You're loading something like: >>>>>>> >>>>>>> myhost/123123/this-is-the-**titl**e-slug >>>>>>> >>>>>>> ? >>>>>>> >>>>>>> On Tuesday, January 15, 2013 3:17:50 PM UTC-6, NP wrote: >>>>>>>> >>>>>>>> I'm trying to implement url slugs in my app (python-based). I want >>>>>>>> the slugged URL to be of the format myhost/<post_id>/<post_title> >>>>>>>> >>>>>>>> When I try to access the page using the above slugged url format, I >>>>>>>> get an error and (in Chrome, the error says - unexpected token <). If >>>>>>>> I >>>>>>>> delete the '/<post_title>' from the url, the page loads correctly. >>>>>>>> Specifically, I noticed that once I have a 'forward slash' after the >>>>>>>> <post_id>, I have issues. Everything works fine without that extra >>>>>>>> slash >>>>>>>> (extra directory) >>>>>>>> >>>>>>>> My code is >>>>>>>> >>>>>>>> class mainhandler(webapp.**RequestHand**ler): >>>>>>>> def get(self): >>>>>>>> if (self.request.path == '/test'): >>>>>>>> path = os.path.join (os.path.dirname (__file__), >>>>>>>> 'test.htm') >>>>>>>> self.response.headers ['Content-Type'] = 'text/html' >>>>>>>> self.response.out.write (template.render (path, {})) >>>>>>>> else: >>>>>>>> path = os.path.join (os.path.dirname (__file__), >>>>>>>> 'index.htm') >>>>>>>> self.response.headers ['Content-Type'] = 'text/html' >>>>>>>> >>>>>>>> self.response.out.write (template.render (path, {})) >>>>>>>> >>>>>>>> application = webapp.WSGIApplication( [('/.*', mainhandler)], >>>>>>>> debug=True) >>>>>>>> >>>>>>>> Basically, I want to load the index.htm file and on that file, I >>>>>>>> have javascript which is supposed to extract the post-id from the URL >>>>>>>> and >>>>>>>> do some stuff with it. >>>>>>>> >>>>>>>> Anybody know what I'm doing wrong here? >>>>>>>> >>>>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Google App Engine" group. >>>>> To view this discussion on the web visit https://groups.google.com/d/* >>>>> *msg/google-appengine/-/**WHVS3FVFrwsJ<https://groups.google.com/d/msg/google-appengine/-/WHVS3FVFrwsJ> >>>>> . >>>>> >>>>> To post to this group, send email to google-a...@googlegroups.**com. >>>>> To unsubscribe from this group, send email to google-appengi...@** >>>>> googlegroups.com. >>>>> >>>>> For more options, visit this group at http://groups.google.com/** >>>>> group/google-appengine?hl=en<http://groups.google.com/group/google-appengine?hl=en> >>>>> . >>>>> >>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Google App Engine" group. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/google-appengine/-/sxFetiKClD0J. >>> >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/google-appengine?hl=en. >>> >> >> -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/K6ouQ3ik03wJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
