Cleaning code

This commit is contained in:
Luka 2022-01-14 09:43:50 +01:00
parent 30961c7e1c
commit 6349272534

37
app.py
View File

@ -1,7 +1,5 @@
from datetime import timedelta
import torch
from flask import Flask, request, jsonify, session
from flask import Flask, request
import classla
import gc
@ -24,41 +22,12 @@ nlp_nonstandard_JOS = classla.Pipeline('sl', processors={
app = Flask(__name__)
app.config['SESSION_TYPE'] = 'filesystem'
app.config['SECRET_KEY'] = "78df924389h138g01308ghj0d913"
# app.config['SESSION_PERMANENT']= False
# @app.before_request
# def make_session_permanent():
# session.permanent = True
# app.permanent_session_lifetime = timedelta(seconds=20)
# # app.permanent_session_lifetime = timedelta(minutes=1)
@app.route('/')
def hello_world():
return 'This is my first API call!'
return 'API is running...'
# @app.route('/run', methods=['GET', "POST"])
# def run():
# if 'settings' not in session:
# return jsonify({'status': 'ERROR', 'details': 'No settings uploaded!'})
#
# input_json = request.get_json(force=True)
# doc = session['nlp'](input_json['text'])
#
# return doc.to_conll()
#
# # return 'NOT IN SESSION!\n'
# @app.route('/upload-settings', methods=['POST'])
# def upload_settings():
# input_json = request.get_json(force=True)
# try:
# settings = input_json['settings']
# session['nlp_id'] = classla.Pipeline(**settings)
# except:
# return jsonify({'status': 'ERROR', 'details': 'Incorrect settings!'})
#
# return jsonify({'status': 'OK'})
@app.route('/custom-settings', methods=["POST"])
def custom_settings():
@ -104,4 +73,4 @@ def nonstandard_jos():
if __name__ == '__main__':
app.run(host="0.0.0.0", debug=True)
app.run(host="0.0.0.0")