dlesieur, to python
@dlesieur@fosstodon.org avatar

Hello! I'm David, an experienced builder of web applications and information systems primarily for the scientific research sector.

I enjoy the challenge of complex problems, which I strive to solve with simple and elegant solutions, placing the end user at the core of my analyses.

I have many interests in life, but on Mastodon I will primarily focus on topics related to my work, such as , , , , , , , .

davidism, to python
@davidism@mas.to avatar

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.

davidism, to python
@davidism@mas.to avatar

The next FlaskCon talk starts at 2:45, Extending Flask using the Flask Plugins API, by Abdur-Rahmaan Janhangeer @osdotsystem

davidism, to python
@davidism@mas.to avatar

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! ☀️😎

davidism, to random
@davidism@mas.to avatar

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

davidism, to python
@davidism@mas.to avatar

Next FlaskCon talk starting at 12:30, Introduction to OpenTelemetry with Flask, by Jessica Garson @jessicagarson

davidism, to python
@davidism@mas.to avatar

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.

adamchainz, to python
@adamchainz@fosstodon.org avatar

Short-term contract shared by one of the folks at Foxley Talent.

https://www.linkedin.com/posts/activity-7197142899942113280-8GNb

davidism, (edited ) to random
@davidism@mas.to avatar

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

badrihippo, to webdev
@badrihippo@fosstodon.org avatar

Using other frameworks is when I realise that (and ) actually had a really powerful and advanced form validation system

davidism, to python
@davidism@mas.to avatar

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

davidism, to python
@davidism@mas.to avatar

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 😻

mariatta, to opensource
@mariatta@fosstodon.org avatar

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.

https://flaskcon.com/2024/

davidism, to python
@davidism@mas.to avatar

FlaskCon call for talk proposals closes on May 1 at 23:59 UTC. You have just over a day to submit your proposal! https://flaskcon.com/2024/

joe, to ai

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.

https://i0.wp.com/jws.news/wp-content/uploads/2024/04/Screenshot-2024-04-22-at-5.58.34%E2%80%AFPM.png?resize=1024%2C647&ssl=1

https://i0.wp.com/jws.news/wp-content/uploads/2024/04/Screenshot-2024-04-22-at-5.59.03%E2%80%AFPM.png?resize=1024%2C647&ssl=1

Basic CLI example

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.

https://i0.wp.com/jws.news/wp-content/uploads/2024/04/Screenshot-2024-04-22-at-8.05.20%E2%80%AFPM.png?resize=1024%2C647&ssl=1

If you replace print(output) with print(output['response']), you can more clearly see the important bits.

https://i0.wp.com/jws.news/wp-content/uploads/2024/04/Screenshot-2024-04-22-at-8.09.04%E2%80%AFPM.png?resize=1024%2C647&ssl=1

Basic Web Application Example

The output is very similar to the node-fetch example from earlier this week. Last week, when we looked at how to dockerize a node app, we output an array as an unordered list. Let’s see if we can replicate that result using the output from Ollama.

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.

So, what does the output look like?

https://i0.wp.com/jws.news/wp-content/uploads/2024/04/Screenshot-2024-04-22-at-8.27.30%E2%80%AFPM.png?resize=1024%2C651&ssl=1

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.

https://jws.news/2024/how-to-write-a-python-app-that-uses-ollama/

davidism, to python
@davidism@mas.to avatar

slsa-github-generator v2 now uses upload/download-artifact v4, so I can update those in all the Pallets projects. Turns out the publish workflow for most projects didn't need any changes at all. Only MarkupSafe, with multiple build jobs, needed a little change to use different upload names and combine their downloads. https://github.com/pallets/markupsafe/commit/f4905079ef7573d5c1e8fe1f291f1e353050bc87

davidism, (edited ) to python
@davidism@mas.to avatar

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

mariatta, to python
@mariatta@fosstodon.org avatar

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:

https://flaskcon.com/2024/

davidism, to random
@davidism@mas.to avatar

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/

JonTheNiceGuy, to python
@JonTheNiceGuy@toot.io avatar

Maybe my google-fu has defeated me, but I want to find a sample or template for 's based web application which has:

  • Basic Auth + TOTP or SAML authentication
  • A REST API using API tokens
  • An ORM for database objects
  • An admin interface for manipulating the objects in the ORM

I don't want 12 different howtos documenting how to write an insecure ToDo app using the framework of the week. Also, the same for 's .

Help me you're my only hope.

davidism, to python
@davidism@mas.to avatar

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

davidism, to python
@davidism@mas.to avatar

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

davidism, (edited ) to python
@davidism@mas.to avatar

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!

davidism, to python
@davidism@mas.to avatar

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

sergi, to python
@sergi@floss.social avatar
  • All
  • Subscribed
  • Moderated
  • Favorites
  • normalnudes
  • rosin
  • ngwrru68w68
  • GTA5RPClips
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • thenastyranch
  • Youngstown
  • Durango
  • slotface
  • everett
  • vwfavf
  • kavyap
  • megavids
  • Leos
  • khanakhh
  • cisconetworking
  • cubers
  • InstantRegret
  • ethstaker
  • osvaldo12
  • modclub
  • anitta
  • provamag3
  • tacticalgear
  • tester
  • JUstTest
  • All magazines