|
116 | 116 | "metadata": {},
|
117 | 117 | "outputs": [],
|
118 | 118 | "source": [
|
119 |
| - "app = FastHTML(secret_key='soopersecret')\n", |
120 |
| - "cli = TestClient(app)\n", |
121 |
| - "rt = app.route" |
| 119 | + "def get_cli(app): return app,TestClient(app),app.route" |
| 120 | + ] |
| 121 | + }, |
| 122 | + { |
| 123 | + "cell_type": "code", |
| 124 | + "execution_count": null, |
| 125 | + "id": "4e3d0e99", |
| 126 | + "metadata": {}, |
| 127 | + "outputs": [], |
| 128 | + "source": [ |
| 129 | + "app,cli,rt = get_cli(FastHTML(secret_key='soopersecret'))" |
122 | 130 | ]
|
123 | 131 | },
|
124 | 132 | {
|
|
421 | 429 | "name": "stdout",
|
422 | 430 | "output_type": "stream",
|
423 | 431 | "text": [
|
424 |
| - "Set to 2024-06-09 13:25:46.659017\n" |
| 432 | + "Set to 2024-06-12 08:11:01.624854\n" |
425 | 433 | ]
|
426 | 434 | },
|
427 | 435 | {
|
428 | 436 | "data": {
|
429 | 437 | "text/plain": [
|
430 |
| - "'Cookie was set at time 13:25:46.659017'" |
| 438 | + "'Cookie was set at time 08:11:01.624854'" |
431 | 439 | ]
|
432 | 440 | },
|
433 | 441 | "execution_count": null,
|
|
468 | 476 | "name": "stdout",
|
469 | 477 | "output_type": "stream",
|
470 | 478 | "text": [
|
471 |
| - "Set to 2024-06-09 13:25:46.705099\n" |
| 479 | + "Set to 2024-06-12 08:11:03.878051\n" |
472 | 480 | ]
|
473 | 481 | },
|
474 | 482 | {
|
475 | 483 | "data": {
|
476 | 484 | "text/plain": [
|
477 |
| - "'Session time: 13:25:46.705099'" |
| 485 | + "'Session time: 08:11:03.878051'" |
478 | 486 | ]
|
479 | 487 | },
|
480 | 488 | "execution_count": null,
|
|
502 | 510 | "\n",
|
503 | 511 | "<!-- do not remove -->\n",
|
504 | 512 | "\n",
|
505 |
| - "## 0.0.9\n", |
| 513 | + "## 0.0.10\n", |
506 | 514 | "\n",
|
507 | 515 | "### New Features\n",
|
508 | 516 | "\n",
|
509 |
| - "- Module `_\n" |
| 517 | + "- sortable\n" |
510 | 518 | ]
|
511 | 519 | }
|
512 | 520 | ],
|
|
528 | 536 | "outputs": [],
|
529 | 537 | "source": [
|
530 | 538 | "auth = user_pwd_auth(testuser='spycraft')\n",
|
531 |
| - "app = FastHTML(middleware=[auth])\n", |
532 |
| - "cli = TestClient(app)\n", |
| 539 | + "app,cli,rt = get_cli(FastHTML(middleware=[auth]))\n", |
533 | 540 | "\n",
|
534 |
| - "@app.route(\"/locked\")\n", |
| 541 | + "@rt(\"/locked\")\n", |
535 | 542 | "def get(auth): return 'Hello, ' + auth\n",
|
536 | 543 | "\n",
|
537 | 544 | "test_eq(cli.get('/locked').text, 'not authenticated')\n",
|
538 | 545 | "test_eq(cli.get('/locked', auth=(\"testuser\",\"spycraft\")).text, 'Hello, testuser')"
|
539 | 546 | ]
|
540 | 547 | },
|
| 548 | + { |
| 549 | + "cell_type": "code", |
| 550 | + "execution_count": null, |
| 551 | + "id": "97f2553c", |
| 552 | + "metadata": {}, |
| 553 | + "outputs": [], |
| 554 | + "source": [ |
| 555 | + "hdrs, routes = app.router.hdrs, app.routes" |
| 556 | + ] |
| 557 | + }, |
| 558 | + { |
| 559 | + "cell_type": "code", |
| 560 | + "execution_count": null, |
| 561 | + "id": "fa194d53", |
| 562 | + "metadata": {}, |
| 563 | + "outputs": [], |
| 564 | + "source": [ |
| 565 | + "app,cli,rt = get_cli(FastHTMLWithLiveReload())\n", |
| 566 | + "\n", |
| 567 | + "@rt(\"/hi\")\n", |
| 568 | + "def get(): return 'Hi there'\n", |
| 569 | + "\n", |
| 570 | + "test_eq(cli.get('/hi').text, \"Hi there\")\n", |
| 571 | + "\n", |
| 572 | + "lr_hdrs, lr_routes = app.router.hdrs, app.routes\n", |
| 573 | + "test_eq(len(lr_hdrs), len(hdrs)+1)\n", |
| 574 | + "assert app.LIVE_RELOAD_HEADER in lr_hdrs\n", |
| 575 | + "test_eq(len(lr_routes), len(routes)+1)\n", |
| 576 | + "assert app.LIVE_RELOAD_ROUTE in lr_routes" |
| 577 | + ] |
| 578 | + }, |
541 | 579 | {
|
542 | 580 | "cell_type": "markdown",
|
543 | 581 | "id": "ff470ef6",
|
|
0 commit comments