File size: 2,532 Bytes
d90fe14
 
 
 
 
 
 
 
 
 
 
 
aae5e4d
d90fe14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aae5e4d
8d576a1
 
 
 
 
d90fe14
 
 
 
 
 
 
 
 
93b72d6
d90fe14
 
 
 
 
a3ed81a
d90fe14
 
 
 
 
 
 
c80ab1d
d90fe14
 
 
 
 
 
 
aae5e4d
d90fe14
32e715d
8d576a1
d90fe14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import os
from yattag import Doc

## --------------------------------- ###
###        reading: info.txt         ###
### -------------------------------- ###
# placeholders in case info.txt does not exist

def get_article():
  filename = "info.txt"
  placeholder =  "please create an info.txt to customize this text"
  
  title = bkgd = sgd1 = sgd2 = td = limitation = con1 = con2 = con3 = con4 = mems = placeholder
  # check if info.txt is present
  if os.path.isfile(filename):
      # open info.txt in read mode
      info = open(filename, "r")
  
      # read each line to a string
      description = info.readline()
      title = info.readline()
      bkgd = info.readline()
      sgd1 = info.readline()
      sgd2 = info.readline()
      td = info.readline()
      limitation = info.readline()
      con1 = info.readline()
      con2 = info.readline()
      con3 = info.readline()
      con4 = info.readline()
      mems = info.readline()
      #mem2 = info.readline()
      #mem3 = info.readline()
      #mem4 = info.readline()
      #mem5 = info.readline()
      
      # close file
      info.close()
      
  # use yattag library to generate html
  doc, tag, text, line = Doc().ttl()
  # create html based on info.txt
  with tag('div'):
    with tag('div', klass='my-div'):
      line('h2', 'Project Background:')
      line('p', bkgd)
    #with tag('div', klass='my-div'):
      #line('h2', 'Data Collection')
      #line('p', sgd1)
    with tag('div', klass='my-div'):
      line('h2', 'Targeted SDGs and Potential Applications: ')
      with tag('ul'):
        line('li', sgd1)
        line('li', sgd2)
    with tag('div', klass='my-div'):
      line('h2', 'Technical challenges faced during this project:')
      line('p', td)
    with tag('div', klass='my-div'):
      line('h2', 'Limitations of this Project/Gradio Application:')
      line('p', limitation)  
    with tag('div', klass='my-div'):
      line('h2', 'Conclusion and Future Work:')
      with tag('ul'):
        line('li', con1)
        line('li', con2)
        line('li', con3)
        line('li', con4)        
    with tag('div', klass='my-div'):
      line('h2', 'Team Members:')
      line('p', mems)
      
  css = '''
  .my-div {
    border: 2px solid black;
    text-align: center;
    margin: 10px;
    padding: 5%;
  }
  ul {
    display: inline-block;
    text-align: left;
  }
  .description {
    text-align: center;
  }
  '''

  return {
    'article': doc.getvalue(),
    'css': css,
    'title': title,
    'description': description,
  }