Skip to content

Commit

Permalink
Fix routing address problems
Browse files Browse the repository at this point in the history
  • Loading branch information
DraTeots committed Oct 6, 2024
1 parent c0e0413 commit 8fe6aa5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
8 changes: 8 additions & 0 deletions pyrobird/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,11 @@ Serves the asset configuration file (`config.jsonc`) with additional server info
curl "http://localhost:5454/assets/config.jsonc"
```

### Publishing

```bash
hatch build
hatch publish

# You will have to setup your pip authentication key
```
2 changes: 1 addition & 1 deletion pyrobird/src/pyrobird/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# This file is part of Firebird Event Display and is licensed under the LGPLv3.
# See the LICENSE file in the project root for full license information.

__version__ = "0.1.8"
__version__ = "0.1.9"
34 changes: 19 additions & 15 deletions pyrobird/src/pyrobird/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from flask_compress import Compress



# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -155,18 +156,21 @@ def download_file(filename=None):
abort(404) # Return 404 if the file does not exist


@flask_app.route('/api/v1/convert/edm4eic/<string:entries>', methods=['GET'])
@flask_app.route('/api/v1/convert/edm4eic/<string:entries>/<path:filename>', methods=['GET'])
@flask_app.route('/api/v1/convert/<string:file_type>/<string:entries>', methods=['GET'])
@flask_app.route('/api/v1/convert/<string:file_type>/<string:entries>/<path:filename>', methods=['GET'])
@compress.compressed()
def open_edm4eic_file(filename=None, entries="0"):
def open_edm4eic_file(filename=None, file_type="edm4eic", entries="0"):
"""
Opens an EDM4eic file, extracts the specified event, converts it to JSON, and serves it.
If the file is local, it checks if the user is allowed to access it.
If the file is remote (starts with http://, https://, root://), it proceeds without permission checks.
:param filename: The path or URL of the EDM4eic file.
:param entries: The event number to extract.
:return: JSON response containing the event data.
Parameters
----------
filename - Name or URL of the file to open
file_type - String identifying file type: "edm4hep" or "edm4eic" or else...
entries - List of entries, May be one entry, range or comma separated list
"""

start_time = time.perf_counter()
Expand Down Expand Up @@ -262,11 +266,6 @@ def open_edm4eic_file(filename=None, entries="0"):
return jsonify(event)


@flask_app.route('/api/v1/edm4hep/event/<string:entries>', methods=['GET'])
@flask_app.route('/api/v1/edm4eic/event/<string:entries>/<path:filename>', methods=['GET'])
@compress.compressed()
def open_edm4eic_file(filename=None, entries="0"):
return {"error": "Is not implemented"}, 400

@flask_app.route('/assets/config.jsonc', methods=['GET'])
def asset_config():
Expand All @@ -284,11 +283,16 @@ def asset_config():
except Exception as ex:
logger.error(f"error opening {config_path}: {ex}")

host = request.host.split(':')[0]
port = request.host.split(':')[1]
host = 'unknown'
port = 80

tokens = request.host.split(':')

if tokens and tokens[0]:
host = tokens[0]

if not port:
port = 5454
if len(tokens) > 1:
port = tokens[1]

"""
serverPort: number;
Expand Down

0 comments on commit 8fe6aa5

Please sign in to comment.