Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
f267462
1
Parent(s):
9d02916
Update app.py
Browse files
app.py
CHANGED
@@ -2,38 +2,24 @@ import flask
|
|
2 |
from flask import request, jsonify
|
3 |
import os
|
4 |
import json
|
5 |
-
import logging
|
6 |
-
import pandas as pd
|
7 |
from dotenv import load_dotenv
|
8 |
load_dotenv()
|
9 |
-
logging.basicConfig(level=logging.DEBUG, filename='debug.log', filemode='w')
|
10 |
-
|
11 |
app = flask.Flask(__name__, template_folder="./")
|
12 |
-
|
13 |
@app.route('/')
|
14 |
def index():
|
15 |
return flask.render_template('index.html')
|
16 |
-
|
17 |
@app.route("/", methods=["POST"])
|
18 |
def predict():
|
19 |
incoming = request.get_json()
|
20 |
print(incoming)
|
21 |
# Ваша логика обработки текста здесь
|
22 |
return "Your response here"
|
23 |
-
|
24 |
@app.route("/avp", methods=["POST"])
|
25 |
def avp():
|
26 |
incoming = request.get_json()
|
27 |
print(incoming)
|
28 |
-
|
29 |
-
|
30 |
-
data = pd.DataFrame.from_dict(incoming, orient='index', columns=['value'])
|
31 |
-
data['value'] -= 1
|
32 |
-
logging.debug(f"Incoming data: {incoming}")
|
33 |
-
data.loc[data['value'] < 0, 'value'] = 0
|
34 |
-
response = data.to_dict()['value']
|
35 |
-
|
36 |
return jsonify(response)
|
37 |
-
|
38 |
if __name__ == '__main__':
|
39 |
-
app.run(host='0.0.0.0',
|
|
|
2 |
from flask import request, jsonify
|
3 |
import os
|
4 |
import json
|
|
|
|
|
5 |
from dotenv import load_dotenv
|
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("/", methods=["POST"])
|
12 |
def predict():
|
13 |
incoming = request.get_json()
|
14 |
print(incoming)
|
15 |
# Ваша логика обработки текста здесь
|
16 |
return "Your response here"
|
|
|
17 |
@app.route("/avp", methods=["POST"])
|
18 |
def avp():
|
19 |
incoming = request.get_json()
|
20 |
print(incoming)
|
21 |
+
# Обработка POST запроса по пути "/avp"
|
22 |
+
response = {"bazis": incoming["bazis"]}
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
return jsonify(response)
|
|
|
24 |
if __name__ == '__main__':
|
25 |
+
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|