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 #Python #Flask #MarkupSafe #GitHub #SLSA

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 #Python 's #Flask 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 #PHP 's #Laravel.

Help me #lazyweb 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 #Python #MarkupSafe #Flask

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 #Python #MarkupSafe #Flask

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! #PyCon #PyConUS #Python #Flask

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 #Python #ItsDangerous #Flask

sergi, to python
@sergi@floss.social avatar
davidism, to python
@davidism@mas.to avatar

I'm starting to think of sdists as an intermediate build between repo and wheel, rather than a partial representation of the repo. Sdists should only contain the code and metadata needed to create the wheel, not docs, dev requirements, examples, tests, and other tool config. All that extra stuff can be run by checking out the tag and using our standard contributor instructions. Removing that from sdists would probably save PyPI a good amount of bandwidth. #Python #Flask

flaskcon, to random
@flaskcon@hachyderm.io avatar

Flaskcon 2024 call for proposals is now live.

Come share your experience with everyone and join the fun!

Flaskcon is inside PyCon US this year so there’s more fun for everyone.

https://flaskcon.com/2024/

#flaskcon #Flaskcon2024 #flask #pycon2024

davidism, to python
@davidism@mas.to avatar

Just released Flask 3.0.3 with a fix for overly-eager FIPS systems that have already disabled SHA-1. The default remains SHA-1 (within HMAC), but it won't fail on import in FIPS anymore. https://github.com/pallets/flask/releases/tag/3.0.3

vmaurin, to python
@vmaurin@fosstodon.org avatar

Apparently, in python web ecosystem, /foo/bar and /foo%2Fbar are interpreted the same (but not /foo?bar and /foo%3Fbar at least) 🤦

danielsiepmann, to python

My boyfriend uses the vacation to learn programming.

He finished basic HTML and is currently working on CSS.

He want to do web development based on #python.

Any recommendations for totally new unexperienced people to get started with python web development?

Django and other frameworks look way too much compared to php. Is there an easy entry?

olkol,
archipylago, to python
@archipylago@mementomori.social avatar

Our next event is a sprint at SparkUp Sat 13.4. 12-16 and the theme is web development with Python using Django, Flask or FastAPI.

Our sprints are hands-on programming events where we gather together to learn about a given theme. Collaborating with others, asking questions and helping each other find the answers is at the heart of these events.

More information and registration at https://archipylago.dev/blog/april-sprint-web-development/

hl, to RaspberryPi
@hl@social.lol avatar

It lives! Now my home sensor network has a way to see the data, thanks to a locally hosted website: https://www.henryleach.com/2024/02/home-sensor-network-part-7-visualisation-website

#projects #raspberrypi #iot #flask #python #plotly

itnewsbot, to windows
@itnewsbot@schleuss.online avatar

Streaming Deck Removes Need for Dedicated Hardware - Streaming content online has never been more popular than it is now, from YouTube ... - https://hackaday.com/2024/02/25/streaming-deck-removes-need-for-dedicated-hardware/ #touchscreen #videohacks #smartphone #toolhacks #browser #control #webdeck #windows #python #qrcode #remote #stream #tablet #flask #twich

TEG, to python
@TEG@mastodon.online avatar

My hosting provider is discontinuing Passenger on my current plan. Does anyone know of what options are good currently, especially for people like me who don't really know what they're doing and just want Python/Flask apps to go brrrr?

#python #passenger #flask

davidism, to python
@davidism@mas.to avatar

Just released Flask-Alembic 3.0! This extension combines Flask and Flask-SQLAlchemy with the Alembic migration library, providing CLI and programatic access to Alembic's functionality. It went 7.5 years without needing a release. This fixes compatibility with Flask-SQLAlchemy 3.1, and generally modernizes the project, tooling, and minimum requirements. https://github.com/davidism/flask-alembic/releases/tag/3.0.0

  • All
  • Subscribed
  • Moderated
  • Favorites
  • anitta
  • ngwrru68w68
  • hgfsjryuu7
  • InstantRegret
  • Youngstown
  • rosin
  • slotface
  • everett
  • mdbf
  • ethstaker
  • kavyap
  • thenastyranch
  • DreamBathrooms
  • PowerRangers
  • Leos
  • magazineikmin
  • Durango
  • cubers
  • GTA5RPClips
  • cisconetworking
  • tacticalgear
  • osvaldo12
  • khanakhh
  • vwfavf
  • tester
  • modclub
  • normalnudes
  • provamag3
  • All magazines