@anvil.server.route in Anvil Apps?

After the announcement for py.space, I noticed that the @anvil.server.route was also showing up in Anvil. In fact, when I added that, this also started appearing on the bottom of the screen

However, when I actually went to that path, I got an error in my app logs
AttributeError: module 'anvil.server' has no attribute 'route'

Is it just a glitch (a py.space only feature that somehow made it to Anvil) or can I finally expect to see this happening.

1 Like

Yes, this will be making its way to all of Anvil! Right now, it’s only in Python 3.10. Docs coming soon!

4 Likes

That’s great! Didn’t know I had to switch to Python 3.10. I did that and now it works!

Since I use browser routing on my Anvil apps, this will be really helpful for me (since all my previous links had _/api in them making them really long.

Edit: I just realized that it also solves Adding ads.txt to Anvil App

Oh no!!!

The biggest limitation of Anvil is going away!

Tons of forum posts are becoming obsolete!

I’ll need to finally make all the apps that couldn’t make earlier!

:partying_face:
:tada:
:birthday:
:clinking_glasses:

5 Likes

Curious about your use cases for this! I’m just learning about routes since I haven’t really used other frameworks

For starters, you can now upload anything to the root domain of the website (for example robots.txt, ads.txt, favicon.ico) and more.

However, for my use case, it is also very useful since I use browser routing

1 Like

I use the routing module from Anvil Extras in all my apps, so I can bookmark every page, I can send notification emails with links to a specific app state (page), and I can cache pages already visited (when it makes sense).

I don’t know if the native @anvil.server.route coming up soon will be as refined. Perhaps it will be targeting the SEO problem only and I will keep using the good old Anvil Extras, or perhaps it will include caching and even more options, and it’s time for the Anvil Extras routing module to retire. We will see the details when it comes out.


Most of my apps are for internal use, so I don’t really miss a real routing, but in the past I have said “no, I can’t do that” when I was asked to do anything searchable from Google.

For example we use OpenCart for our ecommerce site, which has limitations with the inventory management and the shipment cost calculation. The first idea was to remake the whole ecommerce site in Anvil, but we couldn’t, because Google wouldn’t see it. So I created an OpenCart extension in php, with enough php to call some Anvil endpoints, and created the shipment cost calculator, inventory management and shipment configurator apps in Anvil.

2 Likes

Actually, I will be releasing a dependency for Browser Routing soon (I have already built an internal dependency for my apps) which lessens the SEO problem. Seeing this feature get implemented makes things even better.

1 Like

If this works on the client side forms it’ll certainly be cleaner than hash based routing! And having the SEO benefit - I’ll be able to incorporate landing pages for my apps :slight_smile:

1 Like

Yes, it indeed gives satisfactory results.

https://www.google.com/search?q=site%3Ageeke.app%2F_%2Fapi%2F&oq=site%3Ageeke.app%2F_%2Fapi%2F&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQRRg7MgYIAhBFGDsyBggDEEUYOzIGCAQQRRg6MgYIBRAuGEDSAQg2OTM3ajBqMagCALACAA&sourceid=chrome&ie=UTF-8

Short answer: Watch this space!

Longer answer: Yes, it is absolutely our goal to make proper multi-URL apps with smooth, easy navigation and client side routing; this is a (big, but early) step along that road! (We also recognise that routing is never 100% one-size-fits-all, so we intend to expose the low-level building blocks to people who want to build their own.)

2 Likes

Keeps getting better and better!