File size: 2,033 Bytes
6fba675
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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 = data_collection = priv_cons = bias_cons = ident_cons = img_src = membs = description = 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 = "An AI project created by " + info.readline()
      title = info.readline()
      bkgd = info.readline()
      data_collection = info.readline()
      priv_cons = info.readline()
      bias_cons = info.readline()
      ident_cons = info.readline()
      img_src = info.readline()
      membs = 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', data_collection)
    with tag('div', klass='my-div'):
      line('h2', 'Ethical Considerations')
      with tag('ul'):
        line('li', priv_cons)
        line('li', bias_cons)
        line('li', ident_cons)
    with tag('div', klass='my-div'):
      line('h2', 'Our Team')
      line('p', membs)
      doc.stag('img', src=img_src)
      
  css = '''
  .my-div {
    border: 2px solid black;
    text-align: center;
    margin: 10px;
    padding: 5%;
  }
  ul {
    display: inline-block;
    text-align: left;
  }
  img {
    display: block;
    margin: auto;
  }
  .description {
    text-align: center;
  }
  '''
  return {
    'article': doc.getvalue(),
    'css': css,
    'title': title,
    'description': description,
  }