Hello,
I am relatively new to RenPy and am developing an application that sends game decisions at the end of a game run to a server for evaluation. Intuitively I wanted to solve this with POST requests, but according to the documentation this doesn't work. At the moment I am afraid that this is not possible with RenPy Web. But I wanted to ask here if someone who knows better knows a workaround or can confirm that it is not possible.
The server on which the RenPy application is running is the same one to which the data should be sent.
Thanks in advance for the answers!
Sending Data from RenPy-Web-App to Server
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
-
- Newbie
- Posts: 4
- Joined: Sun Oct 22, 2023 5:42 pm
- Contact:
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Sending Data from RenPy-Web-App to Server
This is kind of hard to do, because of the security implications of the web. What you have to do is to use the emscripten module to execute javascript that calls the fetch api.
As a question, what sort of data are you trying to send? I'm wondering if I could come up with a fairly limited API that works on both desktop Ren'Py and in the browser (perhaps something that takes json and returns json).
As a question, what sort of data are you trying to send? I'm wondering if I could come up with a fairly limited API that works on both desktop Ren'Py and in the browser (perhaps something that takes json and returns json).
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
-
- Newbie
- Posts: 4
- Joined: Sun Oct 22, 2023 5:42 pm
- Contact:
Re: Sending Data from RenPy-Web-App to Server
First of all, thank you for your answer!
Indeed, I am trying to send only one string. I would like to be able to use this for the evaluation of the decision sequence. Sending a json should be sufficient accordingly.
So I need to run "emscripten.run_script(script)". A POST request to a random JSON API seems to work. So now I guess I just need to get my server to accept and process these requests! But this is not a RenPy problem . Thank you very much! I was on the verge of despair! I'm learning to love RenPy and its possibilities more and more !
Indeed, I am trying to send only one string. I would like to be able to use this for the evaluation of the decision sequence. Sending a json should be sufficient accordingly.
So I need to run "emscripten.run_script(script)". A POST request to a random JSON API seems to work. So now I guess I just need to get my server to accept and process these requests! But this is not a RenPy problem . Thank you very much! I was on the verge of despair! I'm learning to love RenPy and its possibilities more and more !
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Sending Data from RenPy-Web-App to Server
I just added the renpy.fetch function to Ren'Py. It handles contacting the server, and works the same way on desktop, mobile, and web.
It will be in tomorrow's nightly.
It will be in tomorrow's nightly.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
-
- Newbie
- Posts: 4
- Joined: Sun Oct 22, 2023 5:42 pm
- Contact:
Re: Sending Data from RenPy-Web-App to Server
Hi, I have just tried out the new function.
It works on my desktop client, but not on my server in the browser. In my browser console, I get "Uncaught SyntaxError: missing ) after argument list" as an error message. Maybe I'm doing something wrong or maybe there's a bug? Btw.:Thanks again for this new function! It really helps me out
Code: Select all
teststring = renpy.fetch("http://192.168.56.106:5000", method="POST", json={"test": "idk"})
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Sending Data from RenPy-Web-App to Server
Can you try it with the new nightly? The first version didn't include working web support, and the nightly build process failed the day after, but hopefully things should work now.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
-
- Newbie
- Posts: 4
- Joined: Sun Oct 22, 2023 5:42 pm
- Contact:
Re: Sending Data from RenPy-Web-App to Server
Hi, i've just tried it and it works! Thank you so much for adding this function! You really saved my project
Who is online
Users browsing this forum: Google [Bot]