❗
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Another pure FastHTML method, only dependency is python-fasthtml.""" | |
| import asyncio | |
| import random | |
| from fasthtml.common import * | |
| from starlette.responses import StreamingResponse | |
| sselink = Script(src="https://unpkg.com/[email protected]/sse.js") | |
| htmx_log = Script("htmx.logAll();"), | |
| app, rt = fast_app(hdrs=(sselink,htmx_log)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lst = [190,200,210,70,60,150,170,90] | |
| previous = 0 | |
| streak_length = 0 | |
| for current in lst: | |
| if previous < current: | |
| streak_length += 1 | |
| else: | |
| print(streak_length) | |
| previous = 0 |
- Build the project locally to make sure it builds
pip install -U build
python -m build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pydantic | |
| def to_json(cls): | |
| cls.to_json = lambda self: pydantic.RootModel[cls](self).model_dump_json() | |
| return cls | |
| @to_json | |
| @pydantic.dataclasses.dataclass | |
| class A: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git rebase -i HASH | |
| # Change code here | |
| git commit --all --amend --no-edit -n | |
| git rebase --continue |
@app.command()
def serve(site: Path = Path("site")):
"""Serve the site"""
check_call(["python", "-m", "http.server", "8000", "-d", site])@app.command()
def serve2(site: Path = Path("site"), port: int = 8000):
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import glob | |
| from dj_notebook import activate | |
| def test_thing(): | |
| print(os.getcwd()) | |
| os.chdir("tests/django_test_project") | |
| print(glob.glob("*")) |