-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
34 lines (26 loc) · 798 Bytes
/
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
from flask import Flask, render_template, request
from pymongo import MongoClient
app = Flask(__name__)
client=MongoClient("mongodb://localhost", 27017)
db=client.wooseongweb
@app.route("/")
def index():
return render_template('index.html')
@app.route("/write", methods=["GET", "POST"])
def write():
if request.method=="POST":
name = request.form.get("name")
title = request.form.get("title")
contents = request.form.get("contents")
inf ={
"name":name,
"title":title,
"contents":contents
}
db.boaard.insert_one(inf)
print(name, title, contents)
return ""
else:
return render_template("write.html")
if __name__ == "__main__":
app.run(debug=True)