first commit

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
陈辅元
2026-07-16 11:12:17 +08:00
co-authored by Cursor
commit 4003624b8c
80 changed files with 9990 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
"""Serve RAG-cut frontend static files (development mode).
Requires the API backend to be running separately:
python backend/run.py
"""
from __future__ import annotations
import argparse
import http.server
import socketserver
from pathlib import Path
FRONTEND_DIR = Path(__file__).resolve().parent
DEFAULT_API = "http://127.0.0.1:8000"
class FrontendHandler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=str(FRONTEND_DIR), **kwargs)
def main() -> None:
parser = argparse.ArgumentParser(description="Start RAG-cut frontend dev server")
parser.add_argument("--host", default="127.0.0.1", help="Bind host (default: 127.0.0.1)")
parser.add_argument("--port", type=int, default=5173, help="Bind port (default: 5173)")
args = parser.parse_args()
url = f"http://{args.host}:{args.port}"
socketserver.TCPServer.allow_reuse_address = True
with socketserver.TCPServer((args.host, args.port), FrontendHandler) as httpd:
print(f"Frontend: {url}")
print(f"API: {DEFAULT_API} (start with: python backend/run.py)")
print("Press Ctrl+C to stop.")
httpd.serve_forever()
if __name__ == "__main__":
main()