-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample2.py
executable file
·45 lines (36 loc) · 1.04 KB
/
example2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import os
from flask import Flask, render_template, redirect, url_for, request
from pycoyote import DIV, SPAN, Component
app = Flask(__name__, static_folder='static')
@app.route('/')
def home_page():
return render_template(
'index.html',
content = MainPage(
{"color": "green"},
DIV("Example ends here")
)
)
def main():
app.run(debug=True)
class MainPage(Component):
def render(self):
return DIV(
# You can pass class as list if you need multiple classes
# You can pass style as dict if you need multiple styles
SPAN(
{
"class": ["bold","italic"],
"style": {
"background-color": self.props['color'],
"font-family": "'Arial', sans-serif"
}
},
"Hello world!"
),
*self.children
)
if __name__ == '__main__':
main()