-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
39 lines (28 loc) · 1.03 KB
/
app.py
File metadata and controls
39 lines (28 loc) · 1.03 KB
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
from flask import Flask, request, render_template
from updatejson import HandleJson
import os
from emailapi import EmailAPI
from handleexcel import HandleExcel
app = Flask(__name__)
handle_json = HandleJson()
send_mail = EmailAPI()
handle_excel = HandleExcel()
class Main:
@app.route('/')
def index():
return render_template('form.html')
@app.route('/submit-form', methods =['POST'])
def submit_form():
firstname = request.form.get('firstname')
lastname = request.form.get('lastname')
data = {
'firstname': firstname,
'lastname': lastname
}
handle_json.update_json(form_details_to_update=data, current_json_file='formdetails.json')
form_details_path = os.path.join(os.getcwd(), 'formdetails.json')
handle_excel.form_details_to_excel(form_details_path)
send_mail.send_email_with_attachment('formdetailsexcel.xlsx')
return 'submited successfully'
if __name__ =='__main__':
app.run(debug=True)