Anonymous
Not logged in
Talk
Contributions
Log in
Request account
Rest of What I Know
Search
Editing
Blog/2024-02-22/Moon Landings
From Rest of What I Know
Namespaces
Page
Discussion
More
More
Page actions
Read
Edit
History
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
Possibly the most unbelievable story I read today was that [https://arstechnica.com/space/2024/02/a-little-us-company-makes-history-by-landing-on-the-moon-but-questions-remain/ there was a private moon landing] and it almost didn't happen because the nav lasers crapped out. The guys on the ground then used the NASA payload's cameras to perform that function! Speaking of these lasers, why do they always manage to do this? There's a whole plane that flies along with Maverick in the new Top Gun whose whole job is to help him get a lock so he can bomb the target but those guys just fly along and then fail to actually get a lock! Made them look like chumps. Recently also tried `fastapi` with `uvicorn` and it is an unbelievably pleasant experience. The harder part was configuring the Kubernetes ingress on EKS and so on, but when I had to do it on our own k3s cluster running Traefik everything was super easy. β<syntaxhighlight lang="python" line> import aiomysql from fastapi import FastAPI, HTTPException app = FastAPI() db_pool: aiomysql.pool.Pool | None = None async def get_db_pool(): import os global db_pool if db_pool is None: db_pool = await aiomysql.create_pool( host=os.environ.get("DB_HOST"), port=3306, user=os.environ.get("DB_USERNAME"), password=os.environ.get("DB_PASSWORD"), db=os.environ.get("DB_DATABASE"), minsize=5, maxsize=10 ) return db_pool @app.on_event("startup") async def startup(): global db_pool db_pool = await get_db_pool() @app.on_event("shutdown") async def shutdown_event(): global db_pool if db_pool: db_pool.close() await db_pool.wait_closed() CATEGORIES = {"animals", "lamps"} @app.get("/products/") async def get_things( category: str = None, ): if category not in CATEGORIES: raise HTTPException(status_code=400, detail=f"Not a valid category from {CATEGORIES}") return [{"name": "thing1"}, {"name", "thing2"}] β</syntaxhighlight> Pretty straightforward stuff. Maybe 30 s for a quick HTTP server. [[Category:Blog]]
Summary:
Please note that all contributions to Rest of What I Know are considered to be released under the Creative Commons Attribution-ShareAlike (see
Rest of What I Know:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Wiki tools
Wiki tools
Special pages
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs