Closed nfkok closed 3 years ago
The Requests library in Pedal does not allow you to make direct requests, because of Cross-Site Scripting issues. Instead, we rely on the instructor providing a special Url Data file to proxy requests through their static data. This is a little complex, but basically:
You click the Add New
button from the files tab and choose Url Data
. This creates a new file, which will be a JSON dictionary mapping filenames to their exact URLs. Here's an example from an assignment where students access weather data.
{"?weather.json": ["http://forecast.weather.gov/MapClick.php?lat=37.2327&lon=-80.4284&unit=0&lg=english&FcstType=json"]}
You then need to create a new Instructor File
through the files tab. Its name should match the key of the Url Data file, but without the "?" at the start. Make sure you choose "Hidden from students, accessible programmatically". The created filename should have question mark at the start. Inside of that file, you can copy/paste whatever you want that URL to end up returning.
Hi, I just found this interesting project. In the documentation, I saw "PythonToBlocks" and I tried out the web based GUI.
I tried to import "requests" library and use it in the python editor. My code is supposed to work and as simple as:
In normal python console, I would get an output :
<Response [200]>
but the using the BlockPy editor, I get an error message: IOError
I also tried using kwargs:
and i get:
and passing arguments into function also seems impossible:
which gives me:
Can I know are there solutions to these issues? Or do you have a better way or API to wrap my python code into blocks by function which can be imported easily into BlockPy?
*Issue edited after several attempts to test out BlockPy