Skip to content

Commit dce5386

Browse files
committed
Remove useless data in main file
1 parent 7ddd98b commit dce5386

File tree

1 file changed

+1
-97
lines changed

1 file changed

+1
-97
lines changed

app/main.py

Lines changed: 1 addition & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
# For developement server on : $env:FLASK_ENV = "development"
2-
31
# Importing Flask Things
4-
from flask import Flask, render_template, request, session, redirect
5-
6-
7-
# Use our data #
8-
9-
# Forms
10-
from lib.forms import LoginForm, ContactUs, NewPost
11-
12-
# Database
13-
from lib.database import users
2+
from flask import Flask, render_template
143

154
# Starting The App #
165
app = Flask(__name__)
@@ -24,91 +13,6 @@
2413
def index():
2514
return render_template("home.html")
2615

27-
# Blog
28-
@app.route("/blog")
29-
def blog():
30-
return render_template("blog.html")
31-
32-
# About
33-
@app.route("/about")
34-
def about():
35-
return render_template("about.html")
36-
37-
# Who
38-
@app.route("/who")
39-
def who():
40-
return render_template("who.html")
41-
42-
# Contact
43-
@app.route("/contact")
44-
def contact():
45-
contact_form = ContactUs()
46-
return render_template("contact.html", con = contact_form)
47-
48-
# Login
49-
@app.route("/login")
50-
def login():
51-
if 'status' in session:
52-
return redirect("/")
53-
else:
54-
login_form = LoginForm()
55-
return render_template('login.html', login_form = login_form)
56-
57-
# Panel
58-
@app.route("/panel")
59-
def panel():
60-
if 'status' in session:
61-
newpost_form = NewPost()
62-
return render_template("panel.html", new_form = newpost_form)
63-
else:
64-
return redirect("/")
65-
66-
67-
# Actions #
68-
69-
# Login Back-End
70-
@app.route("/submit/", methods = ['POST'])
71-
def submit():
72-
login_form = LoginForm(request.form)
73-
if login_form.validate_on_submit():
74-
form_id = login_form.id.data
75-
form_username = login_form.username.data
76-
form_password = login_form.password.data
77-
78-
if form_id in users:
79-
if form_username == users[form_id][0] and form_password == users[form_id][1]:
80-
session['status'] = True
81-
session['username'] = form_username
82-
return redirect("/panel")
83-
else:
84-
return render_template("Error/error.html", context = ['User Error', 'Sorry, Username or Password is incorrect'])
85-
else:
86-
return render_template("Error/error.html", context = ['User Error', 'Sorry, This user is not found'])
87-
88-
# Logout Back-End
89-
@app.route("/logout")
90-
def logout():
91-
session.pop('status', None)
92-
return redirect("/")
93-
94-
# Subscribe Back-End
95-
@app.route("/subscribe/", methods = ['POST'])
96-
def subscribe():
97-
contact_form = ContactUs(request.form)
98-
if contact_form.validate_on_submit():
99-
form_username = contact_form.email.data
100-
101-
return form_username
102-
103-
# New Post Back-End
104-
@app.route("/newpost/", methods = ['POST'])
105-
def newpost():
106-
new_form = NewPost(request.form)
107-
if new_form.validate_on_submit():
108-
form_title = new_form.title.data
109-
form_text = new_form.text.data
110-
111-
11216
# Errors #
11317

11418
# 404 Page Not Found

0 commit comments

Comments
 (0)