Pallets and Flask office hours in PyCon room 317 from 3:15 to 5:30. Please come by to say hi and talk with us about your projects and our projects! I might be showing of a new Flask-SQLAlchemy idea for a more lightweight and type checkable implementation. #PyCon#FlaskCon#Python#Flask
Apparently the convention center is using a product, Voltus, built on Flask and APIFlask to manage its energy use and respond to demand. So cool! ☀️😎 #PyConUS#FlaskCon#Python#Flask
FlaskCon will resume after the PyCon lunch, with Adding OpenAPI to a Flask Application with APIFlask by Will Lachance. Starts at 2:00 in room 317 #FlaskCon#Flask#PyConUS
Finally got all three years of FlaskCon Online (2020, 2021, 2023) up on https://pyvideo.org FlaskCon 2024 videos should be up soon after we have some time to edit and upload. #FlaskCon#Python#Flask
FlaskCon is Friday inside PyCon! Room 317, my opening "State of Pallets" talk starts at 11am, after the opening PyCon keynote. Then we have four talks, then office hours, as well as sprints starting Monday. Please come by to watch the talks and to talk with us about your projects and our projects! https://flaskcon.com#PyConUS#Flask
Just released Werkzeug 3.0.3 with a security fix for a high vulnerability. If an attacker can get you to interact with their domain, and can guess a route in your app that raises an exception, and you're running the debbuger, they can use the fact that public DNS can point to 127.0.0.1 to execute code through the debugger running on localhost. https://github.com/pallets/werkzeug/security/advisories/GHSA-2g68-c3qc-8985#Python#Flask#Werkzeug
I'll be presenting a new talk, "Magical (or not) GraphQL", at North Bay Python 2024! Introducing a new open source library I wrote for work, how I wrote it, cool things to do with GraphQL, and what I've discovered I want instead of GraphQL. Hopefully the barn cats will be interested too 😻 #Python#nbpy#GraphQL#Flask
Last call for signing up to give lightning talks at FlaskCon @ PyCon US 2024.
If you use Flask, Click, Jinja or other parts of Pallets project, this is your opportunity to share your experience with the community.
Yesterday, we looked at how to write a JavaScript app that uses Ollama. Recently, we started to look at Python on this site and I figured that we better follow it up with how to write a Python app that uses Ollama. Just like with JavaScript, Ollama offers a Python library, so we are going to be using that for our examples. Also just like we did with the JavaScript demo, I am going to be using the generate endpoint instead of the chat endpoint. That keeps things simpler but I am going to explore the chat endpoint also at some point.
Install the Ollama Library
The first step is to run pip3 install ollama from the terminal. First, you need to create a virtual environment to isolate your project’s libraries from the global Python libraries.
At this point, we can start writing code. When we used the web service earlier this week, we used the generate endpoint and provided model, prompt, and stream as parameters. We set the stream parameter to false so that it would return a single response object instead of a stream of objects. When using the python library, the stream parameter isn’t necessary because it returns a single response object by default. We still provide it with a model and a prompt, though.
If you run it from the terminal, the response will look familiar.
If you pip install flask to install flask, you can host a simple HTTP page at port 8080 and with the magic of json.loads() and a for loop, you can build your unordered list.
Every time you load the page, it makes a server-side API call to Ollama, gets a list of large cities in Wisconsin, and displays them on the website. The list is never the same (because of hallucinations) but that is another issue.
Have any questions, comments, etc? Please feel free to drop a comment, below.
MarkupSafe speedup saga continues: my coworker contributed a PR to implement them in Rust now. It uses some pretty clever speedups based on other serialization libraries they surveyed. If anyone is comfortable with Rust, we would appreciate reviews and feedback: https://github.com/pallets/markupsafe/pull/438#Python#RustLang#PyO3#Flask#MarkupSafe
New to PyCon US is FlaskCon, one of the Hatchery programs we accepted this year. This is your opportunity to meet the maintainers of Flask and learn how you can become a contributor.
If you use Flask, this is also a great time to share your experiences with the rest of the community.
SIgn up to give a lightning talk now:
I'm looking forward to FlaskCon inside PyCon this year, but it needs talk proposals from the community to be successful. If you work with Flask or our other libraries, or alongside other web technologies, you have something to share and we want to hear it! Please submit a 5-15 minute talk proposal: https://flaskcon.com/2024/#PyCon#PyConUS#Flask
Update on my "remove MarkupSafe's C speedups" post: @tonybaloney swooped in and found a simple change that make the speedups ~40% faster in the cases where they had become slower. Turns out, if plain strings are the most probable thing you'll be escaping, you should check for that first, not last. So the speedups remain in place. https://github.com/pallets/markupsafe/pull/434#Python#MarkupSafe#Flask
Python has seen significant performance improvements in the last few releases. MarkupSafe has a C extension to speed up operations, but it's now slower in many cases than the plain Python implementation. Having a C extension increases the difficulty of maintenance, builds, releases, and installs. I'm wondering if it's time to drop the speedups. https://github.com/pallets/markupsafe/issues/433#Python#MarkupSafe#Flask
Submit your talk proposal for FlaskCon, inside PyCon US May 17! Are you a developer, contributor, maintainer, designer, admin, or anyone else else who uses Flask, Click, Jinja, their extensions, WSGI, ASGI, HTMX, Tailwind, asyncio, etc? We want to hear you! A talk can be 5-15 minutes, in person. CFP closes April 30, notified May 3. Submit your proposal today: https://flaskcon.com/2024/ Please boost and tell your friends! #PyCon#PyConUS#Python#Flask
Just released ItsDangerous 2.2.0. This modernizes the project config a bit more (the last release was in 2022). It adds some better type annotations for the return value of Serializer.dumps. And it fixes the same potential FIPS issue as that Flask release last week. https://github.com/pallets/itsdangerous/releases/tag/2.2.0#Python#ItsDangerous#Flask