Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Running Bottle in Pythonista and another script also
-
My sense would be that the best approach would be to use the Dropbox API on Pythonista and the builtin Dropbox capabilities of Editorial but to focus your efforts on simplicity and ease of setup/use. Slick and simple will beat convoluted almost every time.
-
@ccc , agreed 😱
-
@Phuket2 said:
I have tried the ways you guys suggested. I couldn't get the server to stop. For testing its ok though. I will just move on. I will use the thread version in Pythonista unless I have problems with it. If I have problems or it's funky, will move it to Editorial. But for testing both options are better than my expectations
This is possible with the latest StaSh. You can fetch it by running
selfupdate -f dev
(please restart Pythonista afterwards).A simple demonstration is as follows:
- StaSh comes with a
httpserver
command. So from StaSh, type and runhttpserver
. This starts the server in a separate thread. - Switch to the Pythonista's builtin console and use
requests
module to talk to the server, e.g.import requests; requests.get('http://localhost:8000').text
- Once you are done with the server, switch to StaSh and press the
CC
button (or Ctrl-C on external keyboard) to stop the server. The thread will be properly terminated with all of its resources (e.g. port number) released.
It is even possible to achieve above effects with just StaSh (i.e. don't need Pythonista console):
- Start the server by
httpserver &
(note the "&" character at the end) - Still inside StaSh, run
curl http://localhost:8000
- To stop the server, first run
jobs
to get the job ID of the running server. The output will be something like[4] Started httpserver.py &
. The number inside the square brackets is the job ID, i.e. 4 in this case. Now runkill 4
to terminate the server.
- StaSh comes with a