cs-master / ml

Machine Learning
0 stars 0 forks source link

Django -Python Web #1

Open ahmsayat opened 6 years ago

ahmsayat commented 6 years ago

urls: https://stackoverflow.com/questions/168113/django-how-do-i-create-a-generic-url-routing-to-views

ahmsayat commented 6 years ago

edit path: open ~/.bash_profile

my working python version: /usr/local/bin/python manage.py runserver

https://www.w3schools.com/w3css/w3css_templates.asp

ahmsayat commented 6 years ago
def to_xml(tree):
        doc = minidom.Document()

        root = doc.createElement('root')
        doc.appendChild(root)

        leaf = doc.createElement('leaf')
        leaf.setAttribute('color', 'white')
        text = doc.createTextNode('Text element with attributes')
        leaf.appendChild(text)

        root.appendChild(leaf)

        leaf_cdata = doc.createElement('leaf_cdata')
        cdata = doc.createCDATASection('CData can contain HTML tags without encoding')
        leaf_cdata.appendChild(cdata)
        root.appendChild(leaf_cdata)

        branch = doc.createElement('branch')
        branch.appendChild(leaf.cloneNode(True))
        root.appendChild(branch)

        mixed = doc.createElement('mixed')
        mixed_leaf = leaf.cloneNode(True)
        mixed_leaf.setAttribute('color', 'black')
        mixed_leaf.setAttribute('state', 'modified')
        mixed.appendChild(mixed_leaf)
        mixed_text = doc.createTextNode('Do not use mixed elements if it possible.')
        mixed.appendChild(mixed_text)
        root.appendChild(mixed)

        xml_str = doc.toprettyxml(indent="  ")
        with open("minidom_example.xml", "w") as f:
            f.write(xml_str)
        return HttpResponse(xml_str, content_type='application/json')