-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
76 lines (57 loc) · 1.44 KB
/
main.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
from flask import Flask, render_template, request, json, jsonify, redirect
import json
file_name = 'static/jsonData/fileJson.json'
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
@app.route('/cars')
def cars():
return render_template('cars.html')
@app.route('/login')
def login():
return render_template('login.html')
@app.route('/register')
def register():
return render_template('register.html')
@app.route('/auto')
def auto():
return render_template('auto.html')
@app.route('/panel')
def panel():
return render_template('panel.html')
@app.route('/noma')
def noma():
return render_template('noma.html')
@app.route('/newauto')
def newauto():
return render_template('newauto.html')
def jsonRead():
try:
with open(file_name, 'r') as f:
return json.load(f)
except:
create()
def jsonWrite(data):
with open(file_name, 'w') as f:
json.dump(data, f, indent=4)
return jsonRead()
def create():
with open(file_name, 'w') as f:
json.dump({
'USERS' : []
}, f, indent=4)
return jsonRead()
jsonRead()
@app.route('/getData', methods = ["POST", "GET"])
def getData():
data = request.json
db = jsonRead()
db['USERS'].append(data)
jsonWrite(db)
return 'send!'
@app.route('/showData', methods = ["POST", "GET"])
def showData():
return jsonRead()
if __name__ == '__main__':
app.run(debug=True)