-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
119 lines (92 loc) · 3.6 KB
/
app.py
File metadata and controls
119 lines (92 loc) · 3.6 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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import os
import xlsxwriter
from flask import Flask,render_template,request,jsonify
from commonutility import CommonUtility
app = Flask(__name__)
@app.route('/program/projecttest.html')
def projectTest():
return render_template('program/projecttest.html')
@app.route('/program/wordsanimation.html')
def wordsAnimation():
return render_template('program/wordsanimation.html')
@app.route('/program/flowanimation.html')
def flowAnimation():
return render_template('program/flowanimation.html')
@app.route('/')
@app.route('/program')
@app.route('/program/stringsorting.html')
def stringSorting():
return render_template('program/stringsorting.html')
@app.route('/program/populatetable.html')
def populateTable():
return render_template('program/populatetable.html')
@app.route('/program/sendattachment.html')
def sendAttachment():
return render_template('program/sendattachment.html')
@app.route('/program/sendattachment.html/sendAttachmentContent',methods=['POST'])
# add two excel sheets
def sendAttachmentContent():
requestsData=request.json
excelFileName='test.xlsx'
sheetNames=['firstSheet','secondSheet']
heads=['Mark','Name','Age','Degree']
contents=[]
for data in requestsData['students']:
content=[]
content.append(data['mark'])
content.append(data['name'])
content.append(data['age'])
content.append(data['degree'])
contents.append(content)
CommonUtility.createAndWriteToExcel(excelFileName,sheetNames,[heads,heads],[contents,contents],'black','blue')
bodyText='Please Check the attachment!'
attachmentName='testAttachment.xlsx'
CommonUtility.setEmailandSend('Email Test','xiazhai2017@outlook.com',requestsData['emailAddress'],
None,bodyText,excelFileName,attachmentName)
response={'success':True}
return jsonify(response)
@app.route('/interview')
@app.route('/interview/pythonquestions.html')
def pythonQuestions():
return render_template('/interview/pythonquestions.html')
@app.route('/interview/pythonquestions.html/getContent',methods=['POST'])
def getContent():
fileName='pythonQuestions.txt'
questions=CommonUtility.readTxtFile(fileName)
fileName='pythonAnswers.txt'
answers=CommonUtility.readTxtFile(fileName)
return jsonify({'success':True, 'data':{'questions':questions,'answers':answers}})
@app.route('/interview/pythonquestions.html/saveContent',methods=['POST'])
def saveContent():
data=request.json
if(data['type']=='questions'):
fileName = 'pythonQuestions.txt'
else:
fileName = 'pythonAnswers.txt'
result=CommonUtility.writeTxtFile(fileName, data['data'])
return jsonify({'success': result})
@app.route('/interview/pythonquestions.html/deleteContent',methods=['POST'])
def deleteContent():
data=request.json
if (data['type'] == 'questions'):
fileName = 'pythonQuestions.txt'
else:
fileName = 'pythonAnswers.txt'
result=CommonUtility.deleteTxtfile(fileName,data['data'])
return jsonify({'success':result})
@app.route('/signIn',methods=['GET','POST'])
def signIn():
return render_template('signIn.html',title='Sign In')
#has been coded
@app.route('/signOn',methods=['GET'])
def signOn():
return render_template('signOn.html',title='Sign On')
@app.route('/program/functionalprogram.html')
def functionalProgram():
return render_template('program/functionalprogram.html')
@app.route('/program/functionalprogram.html/request',methods=['GET','POST'])
def requestTest():
data=request.json
return jsonify({'success':True, 'data':data})
if __name__ == '__main__':
app.run()