PythonAnywhere Forums

Feature Request: Develop the PythonAnywhere Api

Hi,

This article is written on my smartphone... And that's why i think, developing an api is very useful. Writing a web application with the pythonanywhere editor is very hard on mobile phones. Yeah, of course, i could write it locally and upload it to pythonanywhere, but testing the app and uploading it each time takes too much time for me. So i thought, a simple api would work.

Things i would like to have in the api:


Login/Logout of course

Upload, Copy and Delete Files

Web App Restart

Get Logs (Error, Info,...)

I was very happy, if i could help you creating the api. I also would develop an android app and give you the app as official android client.

Happy coding Famecase

We've been thinking about ways to implement an API actually. How do you feel about basic token authentication? http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication

NB - this is all very much "pie in the sky" at the moment, so no promises re timelines or even whether we will actually do it!

I am very familar with python and web basics. I used Flask but i think using django, etc. will be very easy in this case. If i could help you in any way i would be very happy ;)

Token authentication would be by far the easiest way to implement this.

Maybe this could be linked to https://www.pythonanywhere.com/forums/topic/862/#id_post_6109 ?

It's a long time ago since i posted something here...

I have a question: Which programming language do you use to let people login and upload files? And what web framework do you use? I am very familar with Flask but Django isn't much harder. So i was happy if I could help you to make an api ;)

We use django. We're still experimenting with an API, hopefully we'll be able to publish a beta version soon. Then we would love your help in testing it and building tools for it...

@Dear PA,

Would you like more ideas about possible API methods, or better later?

So far I know about:

https://www.pythonanywhere.com/forums/topic/862/#id_post_6109

https://www.pythonanywhere.com/forums/topic/3800/#id_post_19237

and this thread.

Thanks,

Jim

Hmmmm. Well, for now we're concentrating on getting an API working that would allow users to create and modify (and reload) web apps entries on the Web tab. Our first use-case is going to be for ourselves, to be able to provide some automated webapp creation scripts (bypassing the ui dialog boxes on the web tab).

So we'll at least cover the "reload web app" api that people were asking for, and a few others (create new web app, modify virtualenv/static files settings).

Any strong opinions about what to do next would certainly be taken into consideration, although i can't guarantee they'd make it into the first release...

Sounds great... I think the "reload web app" api is the first step to the final api. After implementing this feature, adding more features shouldn't be very hard. Thank you for your replies ;) That's why i like the PythonAnywhere community. Of course i would be very happy if i could help you. Just send me a mail or post something in this thread here, when i can test the api

Thankyou, Famecastle

Hi everyone, we do have a first cut of the API ready for testing (see blog). Drop us an email to support@pythonanywhere.com if you'd like us to switch it on for your account.

Be aware that the api is an early beta release, and we reserve the right to change it or break it at any time, so it's really just for playing around with at this stage. Don't go building anything important with it!

I see there'should already an api for creating console sessions and opening a browser tab or iframe to connect to them, and apis for killing those consoles. However, I didn't find any apis for reading/writing from those sessions. Being able to communicate with consoles would be great for automated test execution and reporting. Have you considered such an api?

we haven't. or maybe we have, but only in wild flighs of fancy. it would be quite complicated. but not impossible.

in the meantime, getting the logs from scheduled tasks is a little easier, since they are just files in /var/log, that may be a decent compromise?

Scheduled tasks, that's the great idea. I'll take a look at that api. Thanks!

I was thinking... would we be able to make use of the API from the webapp itself? What I mean is, could I write an endpoint on my webapp that would execute a "git pull" and then reload the web app automatically? That way I could automate updating to new versions much faster.

Hmm, that would probably work. Because your request to the API from the web app code will restart the code that's making the request, you may see some errors in the log from time to time, but the restart should happen regardless.