I have a dragon script running on a local dragon. It's not an enterprise app or anything, just something like this With whom I am playing. This "bottle" library uses the app basically uses an XML file (locally or stored online) which have some unique coordinates with their own unique ID, for example mysite.com/23 The length of the element will bring back / long I'm sure you are familiar with REST with everyone at this level.
Now, I want to do it online, but there is a problem finding a host that supports "bottle". However, I've got a host that has installed the demo.
So, my question is, how difficult would it be to convert the following code from a bottle to a dengue? And can someone give me some signs? I have tried to use common dragon libraries.
Thank you. Import from xml.dom.minidom import parseString to bottle import path, import xml import urlib file = open ('Myfile.xml', 'r') data = file.read () dom = parseString (data) @ root ('/ : Number ') Def indices (number = "1"): rows = dom.getElementsByTagName ("E-mail" ("Marker") for line in rows [0] .getElementsByTagName ("Marker"): If line GetAttribute ("number") == str (number): return str (xml.dumps) ("long" ": line.get attribute (" lng "), 'late': line.get attribute (" late ")} , Sort_keys = true, indent = 4)) returns "Not found" run (host = 'localhost', port = 8080)
I I took a chance to learn a little bit about Django as a reference.
Starting with an empty Django site ( and WARNING: I have not tested the XML code, only Django-related, which Anne There is a lot of information in the Django book, in which it is positioned on a production server. django-admin.py startproject testite ), I do this
urls.py to: django.conf.urls.defaults import pattern, from:
; URL from testite. View import indicator urlpatterns = pattern ( '', Url (r '^ (\ d +) $', index),)
views.py on: < Pre>
Import in HttpResponse import django.http xml. Dom.minidom import parseString import xml import urllib dig index (request, number): read data = open ('myfile.xml', 'r') (dom) = parseString (data) rows = (dom.getElementsByTagName ("card" ) [0] .getElementsByTagName ("markers") [0] .getElementsByTagName ("marker")) for lines in rows: if the line .getAttribute ("number") == str (number): return HttpResponse (str (xml ("Not found"). Deep ({'long': row.getAttribute ("lng"), 'lat': row.getAttribute ("lat"), sort_keys = true, indent = 4))) / code>
is tested through Python manage.py runerver .
Comments
Post a Comment