-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
58 lines (39 loc) · 1.29 KB
/
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
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
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
from pymongo import MongoClient
client = MongoClient('mongodb+srv://test:[email protected]/Cluster0?retryWrites=true&w=majority')
db = client.dbsparta
@app.route('/')
def main():
return render_template('main.html')
@app.route('/GHS')
def go():
return render_template('GHS.html')
@app.route('/CSH')
def mari():
return render_template('CSH.html')
@app.route('/HJH')
def yee():
return render_template('HJH.html')
@app.route('/NDH')
def kimm():
return render_template('NDH.html')
@app.route('/YJH')
def kimw():
return render_template('YJH.html')
@app.route("/comment", methods=["POST"])
def comment_post():
name_receive = request.form['name_give']
comment_receive = request.form['comment_give']
person_receive = request.form['person_give']
doc = {'name': name_receive,
'comment': comment_receive,
'person': person_receive}
db.collection.insert_one(doc)
return jsonify({'msg':'POST 연결 완료!'})
@app.route("/comment", methods=["GET"])
def comment_get():
comment_list = list(db.collection.find({}, {'_id': False}))
return jsonify({'comments': comment_list})
if __name__ == '__main__':
app.run('0.0.0.0', port=5001, debug=True)