Skip to content

Commit

Permalink
Merge branch 'main' into fix_linux_deployment_2
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Aug 18, 2023
2 parents 57c570f + f7d9222 commit 01c7cc8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 47 deletions.
7 changes: 0 additions & 7 deletions pyflask/apis/startup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""API endpoint definitions for startup operations."""
from startup import get_api_version
from flask_restx import Namespace, Resource

startup_api = Namespace("startup", description="API for startup commands related to the NWB GUIDE.")
Expand All @@ -20,9 +19,3 @@ class Echo(Resource):
def get(self):
args = parser.parse_args()
return args["arg"]


@startup_api.route("/minimum_api_version")
class MinimumApiVersion(Resource):
def get(self):
return get_api_version()
21 changes: 17 additions & 4 deletions pyflask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import sys
import json
import multiprocessing
from logging import Formatter, DEBUG
from logging.handlers import RotatingFileHandler
from pathlib import Path

from flask import Flask, request, send_from_directory
from flask_cors import CORS
from flask_restx import Api, Resource

from apis import startup_api, neuroconv_api
from setupUtils import configureLogger
from manageNeuroconv.info import resource_path, STUB_SAVE_FOLDER_PATH, CONVERSION_SAVE_FOLDER_PATH

app = Flask(__name__)
Expand All @@ -18,8 +19,22 @@
CORS(app)
app.config["CORS_HEADERS"] = "Content-Type"

configureLogger(app)
# Configure logger
LOG_FILE_PATH = Path.home() / "NWB_GUIDE" / "logs" / "api.log"
LOG_FILE_PATH.parent.mkdir(parents=True, exist_ok=True)

log_handler = RotatingFileHandler(LOG_FILE_PATH, maxBytes=5 * 1024 * 1024, backupCount=3)
log_formatter = Formatter(
fmt="%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
log_handler.setFormatter(log_formatter)

app.logger.addHandler(log_handler)
app.logger.setLevel(DEBUG)


# Initialize API
package_json_file_path = resource_path("package.json")
with open(file=package_json_file_path) as fp:
package_json = json.load(fp=fp)
Expand All @@ -29,10 +44,8 @@
title="NWB GUIDE API",
description="The REST API for the NWB GUIDE provided by the Python Flask Server.",
)

api.add_namespace(startup_api)
api.add_namespace(neuroconv_api)

api.init_app(app)


Expand Down
1 change: 0 additions & 1 deletion pyflask/setupUtils/__init__.py

This file was deleted.

25 changes: 0 additions & 25 deletions pyflask/setupUtils/configureLogger.py

This file was deleted.

1 change: 0 additions & 1 deletion pyflask/startup/__init__.py

This file was deleted.

9 changes: 0 additions & 9 deletions pyflask/startup/minimumApiVersion.py

This file was deleted.

0 comments on commit 01c7cc8

Please sign in to comment.