Anvil Server -- When will Routing be available

What I’m trying to do:
Run my app with routes on the local anvil server (including those that have anvil.server.FormResponse returned from them)

What I’ve tried and what’s not working:
I have my app successfully running locally and when I run it through the online editor, my routes work as expected with any kind of valid response. However, when I try to go to the non-origin routes like http://localhost:3030/test, it always gives me this error for both form responses and even just a string.

This response cannot be transmitted over HTTP. You must return either Media, a string, or a JSON-compatible object (lists/dicts/strings/numbers/None)

Am I doing something wrong or does the open source server not have the new routing feature available on it?

No experience with routing, but lots of experience typing web addresses. I noticed you used http. What if you use https?

If I use https it just doesn’t load because I’m just running it on the localhost on my laptop right now and haven’t setup https yet. It doesn’t seem that that would be the issue either since the error is about the types of things you can return from route paths.

Well, the error message does say

And HTTPS is the only logical alternative I can think of.

Also, if it matters, here is the version information for the pip version of anvil-app-server:

Name: anvil-app-server
Version: 1.12.3
Summary: A standalone server for Anvil full-stack Python web apps
Home-page: https://anvil.works
Author: Anvil
Author-email: contact@anvil.works
License: GNU Affero General Public License v3
Location: /home/duncan/.local/lib/python3.10/site-packages
Requires: anvil-uplink, progressbar2, psutil, pychrome, wheel

Hmm, that is a fair point… sigh I was hoping to not have to implement that until close to deployment, but :person_shrugging:

Has anyone tried to setup https for a local IP Address?

I tried to set it up following this article:

But, I can’t set --origin https://localhost without error.

It seems like it might be related to this issue:

can anyone confirm if that’s the case?

Hi,

I am pretty sure it is exactly the same issue.
Apparently, since anvil-app-server version 1.11.0, HTTP endpoints are no longer working. I’ve tried both, using HTTP and HTTPS protocols issuing local certificates. Neither of the options worked.

And since the @anvil.server.route decorator creates an HTTP endpoint, it is not working. Also, if you try to input anything after your app address, (e.g. localhost:3030/{literally_any_string}, you get
This response cannot be transmitted over HTTP. instead of

The only suggestion for now is to use version 1.10.1, as this was the last fully working version of the anvil-app-server. However, @anvil.server.route was not implemented in this version yet, which means that you would also have to change routing to hash navigation until this gets fixed.

@anvil.server.route was not implemented in this version yet, which means that you would also have to change routing to hash navigation until this gets fixed

That’s the real problem with it, cause the routes are all server side and hash routing all client side so it would be a way too massive refactor to bother.

@meredydd any idea on timelines for fixing these issues?

Hi Everyone,

We’ve released v1.13 which includes routing and fixes the API endpoint issue.

You can run pip install anvil-app-server --upgrade to get the latest update. Please let us know if you have any issues.

Thanks,
Ryan

1 Like