From af9f1afb9f6e38e3b4590ed072e886dd4a7ed494 Mon Sep 17 00:00:00 2001 From: Frode Aarstad Date: Mon, 18 Nov 2024 12:49:57 +0100 Subject: [PATCH] Replace Flask with FastAPI --- src/everest/detached/jobs/everserver.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/everest/detached/jobs/everserver.py b/src/everest/detached/jobs/everserver.py index f75c06a1508..449b2bcc9ef 100755 --- a/src/everest/detached/jobs/everserver.py +++ b/src/everest/detached/jobs/everserver.py @@ -16,7 +16,12 @@ from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.x509.oid import NameOID from dns import resolver, reversename -from flask import Flask, Response, jsonify, request +#from flask import Flask, Response, jsonify, request +import uvicorn + +from fastapi import FastAPI, Request, status +from fastapi.responses import HTMLResponse, RedirectResponse, Response + from ropt.enums import OptimizerExitCode from ert.config import QueueSystem @@ -89,7 +94,7 @@ def _opt_monitor(shared_data=None): def _everserver_thread(shared_data, server_config): - app = Flask(__name__) + app = FastAPI() def check_user(password): return password == server_config["authentication"] @@ -149,7 +154,12 @@ def get_opt_progress(): server_config["key_path"], server_config["key_passwd"], ) - app.run(host="0.0.0.0", port=server_config["port"], ssl_context=ctx) + + + uvicorn.run(app, host="0.0.0.0", port=server_config["port"]) + #app.run(host="0.0.0.0", port=server_config["port"], ssl_context=ctx) + + def _find_open_port(host, lower, upper):