|
421 | 421 | "name": "stdout", |
422 | 422 | "output_type": "stream", |
423 | 423 | "text": [ |
424 | | - "Set to 2024-06-03 12:46:09.633470\n" |
| 424 | + "Set to 2024-06-04 09:37:31.288381\n" |
425 | 425 | ] |
426 | 426 | }, |
427 | 427 | { |
428 | 428 | "data": { |
429 | 429 | "text/plain": [ |
430 | | - "'Cookie was set at time 12:46:09.633470'" |
| 430 | + "'Cookie was set at time 09:37:31.288381'" |
431 | 431 | ] |
432 | 432 | }, |
433 | 433 | "execution_count": null, |
|
468 | 468 | "name": "stdout", |
469 | 469 | "output_type": "stream", |
470 | 470 | "text": [ |
471 | | - "Set to 2024-06-03 12:46:10.556040\n" |
| 471 | + "Set to 2024-06-04 09:37:31.332236\n" |
472 | 472 | ] |
473 | 473 | }, |
474 | 474 | { |
475 | 475 | "data": { |
476 | 476 | "text/plain": [ |
477 | | - "'Session time: 12:46:10.556040'" |
| 477 | + "'Session time: 09:37:31.332236'" |
478 | 478 | ] |
479 | 479 | }, |
480 | 480 | "execution_count": null, |
|
491 | 491 | { |
492 | 492 | "cell_type": "code", |
493 | 493 | "execution_count": null, |
494 | | - "id": "021778d1", |
| 494 | + "id": "4121c4ab", |
495 | 495 | "metadata": {}, |
496 | | - "outputs": [], |
| 496 | + "outputs": [ |
| 497 | + { |
| 498 | + "name": "stdout", |
| 499 | + "output_type": "stream", |
| 500 | + "text": [ |
| 501 | + "# Release notes\n", |
| 502 | + "\n", |
| 503 | + "<!-- do not remove -->\n", |
| 504 | + "\n", |
| 505 | + "## 0.0.3\n", |
| 506 | + "\n", |
| 507 | + "- Init release\n", |
| 508 | + "\n", |
| 509 | + "\n" |
| 510 | + ] |
| 511 | + } |
| 512 | + ], |
497 | 513 | "source": [ |
498 | | - "auth = user_pwd_auth('testuser', 'spycraft')\n", |
499 | | - "app = FastHTML(middleware=[auth])\n", |
500 | | - "cli = TestClient(app)\n", |
501 | | - "rt = app.route" |
| 514 | + "@rt(\"/upload\")\n", |
| 515 | + "async def post(uploadfile:str):\n", |
| 516 | + " return (await uploadfile.read()).decode()\n", |
| 517 | + "\n", |
| 518 | + "fn = '../CHANGELOG.md'\n", |
| 519 | + "data = {'message': 'Hello, world!'}\n", |
| 520 | + "with open(fn, 'rb') as f:\n", |
| 521 | + " print(cli.post('/upload', files={'uploadfile': f}, data=data).text)" |
502 | 522 | ] |
503 | 523 | }, |
504 | 524 | { |
505 | 525 | "cell_type": "code", |
506 | 526 | "execution_count": null, |
507 | | - "id": "b46ae684", |
| 527 | + "id": "90341316", |
508 | 528 | "metadata": {}, |
509 | 529 | "outputs": [], |
510 | 530 | "source": [ |
511 | | - "@rt(\"/locked\")\n", |
512 | | - "def get(req): return 'Hello, ' + req.user.display_name\n", |
| 531 | + "auth = user_pwd_auth(testuser='spycraft')\n", |
| 532 | + "app = FastHTML(middleware=[auth])\n", |
| 533 | + "cli = TestClient(app)\n", |
| 534 | + "\n", |
| 535 | + "@app.route(\"/locked\")\n", |
| 536 | + "def get(auth): return 'Hello, ' + auth\n", |
513 | 537 | "\n", |
514 | 538 | "test_eq(cli.get('/locked').text, 'not authenticated')\n", |
515 | 539 | "test_eq(cli.get('/locked', auth=(\"testuser\",\"spycraft\")).text, 'Hello, testuser')" |
|
0 commit comments