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
-
@ccc No, Flask support is not deprecated at all. I've actually added it in 2.0, it's just that the documentation is missing for now. Code completion should still work via Jedi, it's just a bit slower than it would be if it could use the documentation index.
-
@ccc , given the simple job I am trying to do, do you think bottle is the best for the job. From what I read about mini or micro web frame works, bottle seems to be the simplest
-
I updated with the missing line (t.start()), and this did work as written (sorry, this post didnt get posted)
I am not exactly clear how to kill the server though-it survives global clears. Putting a KeyboardException inside the hello() works, but you could also just reuse the app() and just update route, etc.
-
@JonB, thanks. It works like that in Pythonista. If I add some routes to the bottle backend, it does not work as expected. But if I run it again, it works. Some errors are generated, but the new routes are live. But of course it can be fine tuned. Getting late for me now. I will try running the script from the tools menu tomorrow. Also it does say hit control c to quit. I will try sending the ESC seq for control c tomorrow various ways. Maybe that's the answer
-
The issue is there is not a good way to send a KeyboardInterrupt to a Thread.
You might be able to use default_app() and just usebottle.app().routes=[]
to clear out the old routes
-
@JonB , ok I will take a look thanks. I was just thinking about the debugging environment for the control c, as it comes up in the console to stop the server type control c
-
http://flask.pocoo.org/snippets/67/ Works for flask but something similar might work for Bottle.
-
This seems to be a more bottle-y way. I have not tried this on pythonista
-
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
-
Lol, I still haven't got back to this yet. I jump down one rabbit hole to find myself recursively jumping down other rabbit holes 😱ðŸ˜
But I just had a idea the other day. Just wanted to share it in case it's not that dumb or had another use than my idea usage. My idea was just passing files to Editorial via bottle. Since editorial can link/sync to Dropbox in app, could present some interesting sync possibilities. I know this can be done direct to Dropbox with with the API. There was just something appealing about this idea. Anyway, maybe be crap, just a thought.
-
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