Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
c3cea68
1
Parent(s):
a8995cc
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,18 @@
|
|
1 |
import flask
|
2 |
from flask import request, jsonify
|
3 |
-
import os
|
4 |
import json
|
5 |
-
|
6 |
-
load_dotenv()
|
7 |
-
app = flask.Flask(__name__, template_folder="./")
|
8 |
@app.route('/')
|
9 |
def index():
|
10 |
return flask.render_template('index.html')
|
11 |
@app.route("/avp", methods=["POST"])
|
12 |
def avp():
|
13 |
incoming = request.get_json()
|
14 |
-
print(incoming)
|
15 |
# Изменение значений ключей входящего JSON файла
|
16 |
for key in incoming:
|
17 |
# Уменьшаем значение ключа на 1
|
18 |
incoming[key] -= 1
|
19 |
-
#
|
20 |
-
|
21 |
-
json.dump(incoming, f)
|
22 |
-
# Возвращение измененного JSON файла в ответе сервера
|
23 |
-
with open("output.json", "r") as f:
|
24 |
-
response = json.load(f)
|
25 |
-
return jsonify(response)
|
26 |
if __name__ == '__main__':
|
27 |
-
app.run
|
|
|
1 |
import flask
|
2 |
from flask import request, jsonify
|
|
|
3 |
import json
|
4 |
+
app = flask.Flask(__name__)
|
|
|
|
|
5 |
@app.route('/')
|
6 |
def index():
|
7 |
return flask.render_template('index.html')
|
8 |
@app.route("/avp", methods=["POST"])
|
9 |
def avp():
|
10 |
incoming = request.get_json()
|
|
|
11 |
# Изменение значений ключей входящего JSON файла
|
12 |
for key in incoming:
|
13 |
# Уменьшаем значение ключа на 1
|
14 |
incoming[key] -= 1
|
15 |
+
# Возвращение измененного JSON в ответе сервера
|
16 |
+
return flask.jsonify(incoming)
|
|
|
|
|
|
|
|
|
|
|
17 |
if __name__ == '__main__':
|
18 |
+
app.run
|