Skip to content

Commit

Permalink
Fix route handling by disabling redirect_slashes
Browse files Browse the repository at this point in the history
- Disabled `redirect_slashes` in FastAPI app initialization.
- Added routes without trailing slashes to ensure proper request handling.
  • Loading branch information
Lenochxd committed Nov 7, 2024
1 parent 59f3080 commit 7d4c002
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def load_config():
print("Error: 'database-path' is not set or does not exist.")
sys.exit(1)

app = FastAPI(redirect_slashes=True)
app = FastAPI(redirect_slashes=False)

# In-memory store for request counts
request_counts = defaultdict(list)
Expand Down Expand Up @@ -240,8 +240,11 @@ def format_json_dates(data: dict) -> dict:
return data


@app.get('/{platform}/{tid}')
@app.get('/{platform}/{tid}/')
@app.get('/{platform}/{tid}/{asset_type}')
@app.get('/{platform}/{tid}/{asset_type}/')
@app.get('/{platform}/{tid}/{asset_type}/{screen_id}')
@app.get('/{platform}/{tid}/{asset_type}/{screen_id}/')
async def get_nx(platform: str, tid: str, asset_type: str = None, screen_id = 1):
if platform.lower() not in ['nx', 'switch']:
Expand Down

0 comments on commit 7d4c002

Please sign in to comment.