Hi,
I'm new to Google Appengine and Python programming and I've been
having a problem that's just plain driving me nuts!
I want to implement a RESTful style API, such that when I enter:
http://<url>/trend/<trendname>
A page loads and displays information about the trend.
I've already successfully implemented Open Flash Chart 2 and SWFObject
for a "basic" root URL.
e.g. http://<url>/somepage?parameter=xyz
Some of the logic is inside Django templates, but the end result of
the relevant code outputed is this.
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF(
"OFC.swf", "graph",
"450", "450", "9.0.0", "expressInstall.swf",
{ "data-file": "api/graph/LISTALLTIME" });
</script>
So far so good. The relevant "bit" here is the "OFC.swf" reference
which is the Open Flash Chart 2 SWF object we are executing.
The problem comes when I move to a "dynamic" URL.
Here's some of my APP.YAML and the WSGIApplication call.
handlers:
- url: /OFC.swf
static_files: flash/OFC.swf
upload: flash/OFC.swf
- url: /.*
script: twendly.py
application = webapp.WSGIApplication(
[('/', MainPage),
(r'/trend/(.*)', GraphTrend),
(r'/api/graph/(.*)/(.*)',
GraphTrendValues),
(r'/api/graph/(.*)',
GraphValues),
], debug = True)
So when I call http://<appname>/trend/<trendname> everything seems to
work as it should and I end up with this in my HTML
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF(
"/OFC.swf", "graph",
"450", "450", "9.0.0", "expressInstall.swf",
{ "data-file": "api/graph/LIST1HR/watchmen" });
</script>
Looks good BUT it it's not locating the OFC.swf file successfully.
This has bugged me for days and tonight I figured I get rid of the
"trend" directory and do it as a top level URI e.g. change my
WSGI.Application call to this instead:
application = webapp.WSGIApplication(
[('/', MainPage),
(r'/(.*)', GraphTrend),
<==== NOTE CHANGE ON THIS LINE
(r'/api/graph/(.*)/(.*)',
GraphTrendValues),
(r'/api/graph/(.*)',
GraphValues),
], debug = True)
And call http://<appname>/<trendname>
Everything works! Graph loads etc. - this all makes me think it's got
something to do with relative URL paths, but I would of expected /
OFC.SWF to load it from the root where the APP.YAML is redirecting.
For reasons of elegance (and not getting stumped) I really want to
implement it with the "trend" key word as part of the URI, but this
seems to be a no go at the moment.
I'm guessing I need a different configuration for my APP.YAML, but I'm
really stuck.
Can anyone help me out?
Thanks!
Tim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
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
-~----------~----~----~----~------~----~------~--~---