-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
112 lines (80 loc) · 2.19 KB
/
server.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
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
from flask import Flask, request
from db import getData, setData
import bcrypt
from Categories import Categories
from Deals import Deals
from CardsLayouts import Cards
from HeaderImage import Image
from password import salt
from flask.helpers import send_from_directory
# from BackgroundImages import BackImages
from Footer import Footer
from Searching import Searching
from flask_cors import CORS
app = Flask(__name__)
#!Categories
CORS(app)
@app.route("/Categories", methods=["POST", "GET"])
def fetchCategories():
if request.method == "POST":
Categories()
return getData("Categories")
#!Deals
@app.route("/Deals", methods=["POST", "GET"])
def fetchDeals():
if request.method == "POST":
Deals()
return getData("Deals")
#!Cards
@app.route("/Cards", methods=["POST", "GET"])
def fetchCards():
if request.method == "POST":
Cards()
return getData("Cards")
#!Footer
@app.route("/Footer", methods=["POST", "GET"])
def fetchFooter():
if request.method == "POST":
Footer()
return getData("Footer")
#!nav-images
@app.route("/nav-image", methods=["POST", "GET"])
def fetchNavImage():
if request.method == "POST":
Image()
return getData("nav-image")
#!BackgroundImages
@app.route("/BackgroundImages", methods=["POST", "GET"])
def fetchBGImage():
# if request.method == "POST":
# BackImages()
return getData("BackgroundImages")
#!Credentials
@app.route("/Credentials")
def fetchCredentials():
return getData("Credentials")
#!HMenu
@app.route("/HMenu")
def fetchHMenu():
return getData("HMenu")
#!Credentials
@app.route("/Cred", methods=["POST"])
def checkCred():
flag = False
password = bytes(request.json['pass'], 'utf-8')
userName = request.json['user']
data = getData("Credentials")
oPassworwd = data['password']
oUserName = data['username']
if(userName == oUserName):
hashed = bcrypt.hashpw(password, salt)
if(oPassworwd == str(hashed)):
flag = True
return {"authentication": flag}
#!Searching
@app.route("/Search", methods=["POST", "GET"])
def getSearch():
data = Searching(request.json['tag'])
return data
if __name__ == "__main__":
app.run()