Skip to content

Commit e3838b6

Browse files
committed
feat: Redirect *.playstation.net domain to psfree-luckfox.local
1 parent fbef243 commit e3838b6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

serve.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from pathlib import Path
77

8-
from flask import Flask, send_from_directory, jsonify
8+
from flask import Flask, send_from_directory, jsonify, request, redirect
99

1010

1111
app = Flask(__name__, static_folder=None)
@@ -14,6 +14,7 @@
1414
psfree_files_dir = current_files_dir / "PSFree"
1515
static_files_dir = current_files_dir / "static"
1616
is_debug = False
17+
redirect_url = None
1718

1819

1920
@app.route("/api/<path:path>", methods=["POST"])
@@ -49,6 +50,9 @@ def catch_static_routes(path: str = "index.html"):
4950

5051
@app.route("/<path:path>", methods=["GET"])
5152
def catch_all_routes(path: str):
53+
if redirect_url and "playstation.net" in request.host:
54+
return redirect(redirect_url)
55+
5256
file_path = psfree_files_dir / path
5357
return send_from_directory(file_path.parent, file_path.name)
5458

@@ -57,9 +61,11 @@ def catch_all_routes(path: str):
5761
@click.option("--host", default="0.0.0.0", help="Host to run the server on")
5862
@click.option("--port", default=9191, help="Port to run the server on")
5963
@click.option("--debug", is_flag=True, help="Enable debug mode")
60-
def main(host: str, port: int, debug: bool):
61-
global is_debug
64+
@click.option("--redirect-playstation-domain", default=None, type=str, help="Redirect *.playstation.net domain to other URL")
65+
def main(host: str, port: int, debug: bool, redirect_playstation_domain: str):
66+
global is_debug, redirect_url
6267
is_debug = debug
68+
redirect_url = redirect_playstation_domain
6369
app.run(host=host, port=port, debug=debug, threaded=True)
6470

6571

0 commit comments

Comments
 (0)