Spaces:
Runtime error
Runtime error
- app.py +4 -10
- templates/index.html +3 -2
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from flask import Flask, render_template, request, jsonify
|
2 |
# from flask_cors import CORS, cross_origin
|
3 |
from modules.model import summarize
|
4 |
import __main__
|
@@ -10,12 +10,12 @@ app = Flask(__name__)
|
|
10 |
# longTokenizer = BartTokenizer.from_pretrained('sshleifer/distilbart-cnn-12-6')
|
11 |
# longModel = BartForConditionalGeneration.from_pretrained('sshleifer/distilbart-cnn-12-6')
|
12 |
|
13 |
-
@app.route(
|
14 |
def home():
|
15 |
return render_template('index.html')
|
16 |
|
17 |
|
18 |
-
@app.route(
|
19 |
def recommend():
|
20 |
# Get form data
|
21 |
# request_data = request.args.get("input").get_json()
|
@@ -36,12 +36,6 @@ def recommend():
|
|
36 |
|
37 |
pass
|
38 |
|
39 |
-
def main():
|
40 |
-
# app.config['TEMPLATES_AUTO_RELOAD'] = True
|
41 |
-
# app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
|
42 |
-
# app.run(debug=True)
|
43 |
-
app.run(host='0.0.0.0', port=7860)
|
44 |
-
|
45 |
if __name__ == '__main__':
|
46 |
print("Loading BART model and tokenzier . . .")
|
47 |
-
|
|
|
1 |
+
from flask import Flask, render_template, request, jsonify
|
2 |
# from flask_cors import CORS, cross_origin
|
3 |
from modules.model import summarize
|
4 |
import __main__
|
|
|
10 |
# longTokenizer = BartTokenizer.from_pretrained('sshleifer/distilbart-cnn-12-6')
|
11 |
# longModel = BartForConditionalGeneration.from_pretrained('sshleifer/distilbart-cnn-12-6')
|
12 |
|
13 |
+
@app.route("/")
|
14 |
def home():
|
15 |
return render_template('index.html')
|
16 |
|
17 |
|
18 |
+
@app.route("/summarize")
|
19 |
def recommend():
|
20 |
# Get form data
|
21 |
# request_data = request.args.get("input").get_json()
|
|
|
36 |
|
37 |
pass
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
if __name__ == '__main__':
|
40 |
print("Loading BART model and tokenzier . . .")
|
41 |
+
app.run(host="0.0.0.0", port=7860)
|
templates/index.html
CHANGED
@@ -198,9 +198,10 @@
|
|
198 |
// },
|
199 |
// referrerPolicy: 'no-referrer'
|
200 |
// };
|
201 |
-
const inferResponse = await fetch(
|
|
|
202 |
|
203 |
-
return
|
204 |
};
|
205 |
|
206 |
const textGenForm = document.querySelector('#input_form');
|
|
|
198 |
// },
|
199 |
// referrerPolicy: 'no-referrer'
|
200 |
// };
|
201 |
+
const inferResponse = await fetch(`summarize?input=${jsonfile}`);
|
202 |
+
const inferJson = await inferResponse.json();
|
203 |
|
204 |
+
return inferJson;
|
205 |
};
|
206 |
|
207 |
const textGenForm = document.querySelector('#input_form');
|