-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
167 lines (118 loc) · 3.82 KB
/
app.py
File metadata and controls
167 lines (118 loc) · 3.82 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
from flask import Flask, render_template, request, jsonify
from pymongo import MongoClient
app = Flask(__name__)
ip ='mongodb://anti:anti1234test@15.164.50.153'
port = 27017
client = MongoClient('localhost', port)
db = client.anti
@app.route('/')
def index():
return render_template('enter.html')
@app.route('/home', methods= ['GET'])
def home():
return render_template('home.html')
@app.route('/home/poster', methods=['GET'])
def getPoster():
# print('getPoster()')
posters = list(db.poster.find({},{'_id':False}))
return jsonify({'result':'success', 'list':posters})
@app.route('/menu')
def menu():
return render_template('menu.html')
@app.route('/intro')
def intro():
return render_template('intro.html')
@app.route('/q1')
def q1():
return render_template('question1.html')
# q1 test
@app.route('/q1/name', methods=['GET'])
def name():
name = request.form['name']
db.user.insert_one({name: name })
return jsonify({'result': 'success','msg':'성공'})
@app.route('/q2')
def q2():
return render_template('question2.html')
@app.route('/q3')
def q3():
return render_template('question3.html')
@app.route('/q3/list', methods= ['GET'])
def getWord():
print('getWord()')
star = list(db.wordEx.find({},{'_id':False, 'word':True}))
return jsonify({'result': 'success', 'list': star})
@app.route('/q4')
def q4():
return render_template('question4.html')
@app.route('/submit', methods= ['POST'])
def submit():
# print('submit')
# recword1 = request.form['word1']
# recword2 = request.form['word2']
# recword3 = request.form['word3']
# print(recword1+"+"+recword2+"+"+recword3)
# find1 = list(db.wannabe.find({"word":recword1}))
# find2 = list(db.wannabe.find({"word":recword2}))
# find3 = list(db.wannabe.find({"word":recword3}))
# print(find1)
# print(find2)
# print(find3)
# result1 = result2 = result3 = ""
# if find1:
# result1 = find1[0]['path']
# else:
# rand = random.randrange(1,243)
# result1 = list(db.wannabe.find().skip(rand).limit(1))[0]['path']
# if find2:
# result2 = find2[0]['path']
# else:
# rand = random.randrange(1,243)
# result2 = list(db.wannabe.find().skip(rand).limit(1)))[0]['path']
# if find3:
# result3 = find3[0]['path']
# else:
# rand = random.randrange(1,243)
# result3 = list(db.wannabe.find().skip(rand).limit(1)))[0]['path']
##
wordList = request.form.getlist('words[]')
# randList = request.form.getlist('rand[]')
print(wordList)
# print(randList)
path = []
for i in range(len(wordList)):
if wordList[i]:
find = list(db.wannabe.find({"word":wordList[i]}))
if(find):
path.append(find[0]['path'])
else:
path.append("")
else:
path.append("")
return jsonify({'result':'success','words': path})
@app.route('/poster')
def poster():
return render_template('poster.html')
@app.route('/poster/archive', methods =['POST'])
def archive():
poster = request.form['poster']
db.poster.insert_one({'poster':poster})
return jsonify({'result':'success'})
@app.route('/share')
def share():
return render_template('share.html')
@app.route('/share/story', methods=['GET'])
def getStory():
print('getStory()')
story = list(db.story.find({},{'_id':False}))
return jsonify({'result':'success', 'list':story})
@app.route('/share/newstory', methods = ['POST'])
def newStory():
received = request.form['story']
db.story.insert_one({'story':received})
return jsonify({'result':'success'})
@app.route('/about', methods = ['GET'])
def about():
return render_template('about.html')
if __name__ == '__main__':
app.run('0.0.0.0', port=5000, debug=True)