(request: Request)
| 777 | @app.post("/setup", include_in_schema=False) |
| 778 | @app.post("/setup/", include_in_schema=False) |
| 779 | async def setup_submit(request: Request): |
| 780 | if is_runtime_initialized(): |
| 781 | return RedirectResponse(url="/", status_code=303) |
| 782 | |
| 783 | data = await read_setup_payload(request) |
| 784 | admin_password = str(data.get("admin_password") or "") |
| 785 | confirm_password = str(data.get("confirm_password") or "") |
| 786 | site_name = str(data.get("site_name") or "") |
| 787 | |
| 788 | if admin_password != confirm_password: |
| 789 | return setup_response(build_setup_page("两次输入的管理员密码不一致", data), 400) |
| 790 | |
| 791 | try: |
| 792 | setup_options = parse_setup_options(data) |
| 793 | await initialize_system( |
| 794 | admin_password=admin_password, |
| 795 | site_name=site_name, |
| 796 | setup_options=setup_options, |
| 797 | ) |
| 798 | except ValueError as exc: |
| 799 | return setup_response(build_setup_page(str(exc), data), 400) |
| 800 | |
| 801 | if "application/json" in request.headers.get("accept", ""): |
| 802 | return APIResponse(detail={"ok": True, "admin": "/#/admin"}) |
| 803 | return setup_response(build_setup_success_page()) |
| 804 | |
| 805 | |
| 806 | def resolve_theme_root(): |
nothing calls this directly
no test coverage detected