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?
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.
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
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.