Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading flask. #19

Merged
merged 1 commit into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Figgy CLI Changelog:

## 1.2.8
- Upgrading flask and changes required for compatibility for flask 2.2.2

## 1.2.7
- Making Figgy compatible with latest version of MacOs by changing default port to 5111.

Expand Down
2 changes: 1 addition & 1 deletion src/figcli/config/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path

# If cloud has been updated with required changes, please updated REQUIRES_CLI_VERSION in figtools/figgy
VERSION = '1.2.7'
VERSION = '1.2.8'
CLI_NAME = 'figgy'
PROJECT_NAME = 'figgy'

Expand Down
24 changes: 21 additions & 3 deletions src/figcli/ui/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import functools
import logging
import os
import sys
from threading import Thread
from typing import List
from typing import List, Callable, Dict, Any, Tuple

import werkzeug
from flask import Flask, send_from_directory
from flask_cors import CORS

Expand Down Expand Up @@ -57,10 +60,15 @@ def init_controllers(self):
self.controllers.append(InvestigateController('/investigate', self._context, self._svc_registry))
self.controllers.append(OTSController('/', self._context, self._svc_registry))


def run_app(self):
cli = sys.modules['flask.cli']
cli.show_server_banner = lambda *x: None
werkzeug.serving._ansi_style = self.__ansi_style_supressor(werkzeug.serving._ansi_style)

self.app.add_url_rule('/', 'index', self._goto_index, methods=['GET'])
# Todo set back to 127.0.0.1 after docker demos.
self.app.run(host='0.0.0.0', port=5111, debug=False)
self.app.run(host='127.0.0.1', port=5111, debug=False, use_reloader=False)

def _goto_index(self):
return self._serve_page("index.html")
Expand All @@ -70,7 +78,7 @@ def _serve_page(self, file_relative_path_to_root):

def run(self):
# Disables prod Flask warning. Base flask is not an issue due to our single-user case.
os.environ["WERKZEUG_RUN_MAIN"] = "true"
# os.environ["WERKZEUG_RUN_MAIN"] = "true"

CORS(self.app)
for ctlr in self.controllers:
Expand All @@ -84,3 +92,13 @@ def run(self):
app_thread = Thread(target=self.run_app, args=())
app_thread.daemon = True
app_thread.start()


def __ansi_style_supressor(self, func: Callable[..., Any]) -> Callable[..., Any]:
@functools.wraps(func)
def wrapper(*args: Tuple[Any, ...], **kwargs: Dict[str, Any]) -> Any:
if args and isinstance(args[0], str) and args[0].startswith('WARNING: '):
return ''
return func(*args, **kwargs)

return wrapper
2 changes: 1 addition & 1 deletion src/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ git+https://github.com/samuelcolvin/[email protected]


## Figgy UI
flask==1.1.2 # BSD
flask==2.1.2 # BSD
flask-cors==3.0.10 # MIT