-
-
Notifications
You must be signed in to change notification settings - Fork 33
Using AREPL with web frameworks
There are two ways you can use AREPL with web frameworks:
1. Extract code from your web framework into a arepl session and mock the input
This approach works with anything. Just highlight the code you want to test, use the "open highlighted code in new arepl session" command, and mock the input.
2. Add your web framework library to pyGuiLibraries in the settings.
This will activate restart mode, so each time you make a change the webservice will restart. Make sure you call the webservice through the code rather than the command line. For example, in flask you would use app.run().
from arepldump import dump
from flask import Flask
app = Flask(__name__)
@app.route("/<a>")
def hello(a):
html = "<b>Hello World!</b>"
dump() # use this to inspect the state of your local variables
return html
app.run()
AREPL would show the following output at first:
Print Output:
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
-{
}
If you go to the url you will get a 404 not found. Don't worry! Your method requires a argument, so append a random word to the url. For example, http://127.0.0.1:5000/fallafel
Once you do that AREPL should look like below:
Print Output:
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [11/Oct/2018 07:27:08] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [11/Oct/2018 07:18:59] "GET /fallafel HTTP/1.1" 200 -
-{
hello vars line 9: -{
a: "fallafel",
html: "<b>Hello World!</b>"
}
}
It's a open field from here on out - have fun! If you want you can follow the official flask tutorial
3. Use something else entirely.
I suggest trying birdseye. You just add a birdseye annotation to the function you want to debug and when it's called birdseye records your variable and inputs in a very nice fashion.