-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
27 lines (22 loc) · 708 Bytes
/
app.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
from mako.template import Template
import email
import fileinput
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
with open('in.mail') as f:
s = f.read()
msg = email.message_from_string(s)
part = msg.get_payload()[1]
charset = part.get_content_charset()
body = part.get_payload(decode=True).decode(charset)
temp = Template(filename='templates/message.mako', default_filters=['h'])
out = temp.render(_from=msg['From'],
date=msg['Date'],
subject=msg['Subject'],
body=body,
)
return out.encode('utf8')
if __name__ == '__main__':
app.run(debug=True)