-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (25 loc) · 791 Bytes
/
Copy pathapp.py
File metadata and controls
33 lines (25 loc) · 791 Bytes
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
from flask import Flask, render_template, request, redirect
from database import collection
app = Flask(__name__)
# Home Page
@app.route("/", methods=["GET", "POST"])
def index():
if request.method == "POST":
data = {
"name": request.form["name"],
"college": request.form["college"],
"domain": request.form["domain"],
"duration": request.form["duration"]
}
collection.insert_one(data)
return redirect("/")
return render_template("index.html")
# View Page
@app.route("/view")
def view():
users = collection.find()
return render_template("view.html", users=users)
if __name__ == "__main__":
import os
port = int(os.environ.get("PORT", 10000))
app.run(host="0.0.0.0", port=port)