-
Notifications
You must be signed in to change notification settings - Fork 0
/
malimo.py
44 lines (33 loc) · 1.14 KB
/
malimo.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
import os
from flask import Flask, render_template, request, redirect, url_for
from flask_mail import Mail, Message as MailMessage
import json
import requests
app = Flask(__name__)
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = ''
app.config['MAIL_PASSWORD'] = ''
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
mail = Mail(app)
@app.route('/')
def get_malimo_home():
workFilePath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static/media/work_experience.json')
with open(workFilePath, 'r') as work_file:
content = work_file.read()
workData = json.loads(content)
work_file.close()
return render_template('index.html', work_data=workData)
@app.route('/sendMessage', methods=['POST'])
def messenger():
inquirerName = request.form['name']
inquirerEmail = request.form['email']
inquirerMessage = request.form['message']
msg = MailMessage(inquirerMessage,
sender=inquirerEmail,
recipients=["[email protected]"])
mail.send(msg)
return redirect(url_for('get_malimo_home'))
if __name__ == '__main__':
app.run(debug=True)