Wie man vom Kolben übersät, um mit einem bestimmten Pfad zu reagierenPython

Python-Programme
Anonymous
 Wie man vom Kolben übersät, um mit einem bestimmten Pfad zu reagieren

Post by Anonymous »

Ich habe ein Projekt in Flask in Blaupausen für jede App aufgeteilt. Ich möchte die Vorlage jedes Blaupauses schrittweise in React umschreiben, aber ich muss alle in einem React -Projekt sein. index.html Aber wie würde ich/App/Benutzer-Page mit React Router zur richtigen Seite übertragen?

Code: Select all

react_app_bp = Blueprint(
"react_app", __name__, static_folder="static", template_folder="templates"
)

# Serve static assets (JS, CSS)
@react_app_bp.route("/assets/")
def serve_assets(filename):
return send_from_directory(os.path.join(react_app_bp.static_folder, "assets"), filename)

# Serve the React app's entry point
@react_app_bp.route("/", defaults={"path": ""})
@react_app_bp.route("/")
@login_required
def serve_react_app(path):
build_dir = os.path.join(os.path.dirname(__file__), "static")

if path and os.path.exists(os.path.join(build_dir, path)):
return send_from_directory(build_dir, path)

return send_from_directory(build_dir, "index.html")

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post