Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python Render template
#1
Hello,
I've created a template using python, but now I need to generate a .qml file from it, I wanted to work with rendered template but I coudn't go any where Wall
this is my example :

import string
v={'var1':'screen'}
x=string.Template("""
{
id :$var1
width :22
height :123
""")
print'Item: ', x.substitute(v)
y="""
{
id :$sm1
x :11
y :8
width :12
height :65

}
}

"""
print 'Rectangle ' , y%v

I really need your help!
thank u ^^
Reply
#2
Please put your code in Python code tags, you can find help here.

What have you tried so far? What was the result, did you get errors or wrong format?
Reply
#3
this is my code
    # -*- coding: utf-8 -*-
    """
    Created on Thu Apr 26 20:55:49 2018

    @author: Akhou
    """

    import string 
    v={'var1':'screen'}
    x=string.Template("""
    {
    id      :$var1
    width   :22
    height  :123
    """)
    print'Item: ', x.substitute(v)
    y="""
    {
    id      :$sm1
    x       :11
    y       :8
    width   :12
    height  :65
    } 
    """
    print 'Rectangle ' , y%v
now I want to generate a .qml file from it. So I looked on line for an example to follow( atleast to understand the concept) I found that rebder template is able to generate/create a .qml file. I tried this example ( just to understand how it (rendered_teplate) work :
    from flask import Flask, render_template
    from flask import request, jsonify
    app = Flask(__name__)
    @app.route('/', methods=['GET', 'POST'])
    def homepage():
       if request.method == 'POST':
           f1 = request.form['firstVerb'] 
           f2 = request.form['secondVerb']
       return render_template('index.html', f1=f1, f2=f2)

    if __name__ == "__main__":
        app.run(debug=True) 
All I got was that text :
Error:
* Restarting with stat
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What is bug template using python Anldra12 0 931 Nov-02-2021, 11:36 AM
Last Post: Anldra12
  Python C++ Template Equivalent deanhystad 7 3,312 May-04-2021, 07:45 PM
Last Post: deanhystad
  Erreur de code python sur un template rpm de zabbix samba 0 1,898 Apr-02-2021, 09:43 AM
Last Post: samba
  With SplashRequest to run javascript onclick function to render page properly don 0 1,848 Feb-04-2019, 03:29 AM
Last Post: don

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020