Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use Django to write a console app (i.e., text-based & used from a terminal) that runs over the Internet?

There is so much power at the command line. Web pages are for non-power-users. I'd like my Django app to also have a console-based interface so that people can really work fast and not fiddle with graphics and a mouse. Has anyone tried doing something like this using Django? I like the example of heroku -- once you create an account at heroku.com you can do so much at the command line and interact with the server without the overhead of HTTP.

like image 470
Deonomo Avatar asked Dec 15 '25 16:12

Deonomo


1 Answers

This is exactly what the 'shell' command of manage.py does. It gives you a python prompt with a few things set up so you can import your models and mess with them via the django API. So if your command-line tools are for superusers with shell access on the server then you can just write some python scripts that get run in the same way.

However, if you want access to users from other machines then you (obviously?) need to go via HTTP, but python has libraries for doing http requests. The only complication is with logins and cookies, but python's libraries can help you with that too - see urllib2, cookielib etc. You'd have to write some plain-text templates for the returned output.

I have no experience with heroku so I'm not sure what it's doing - what kind of thing can you do at the command line with it?

like image 76
Spacedman Avatar answered Dec 17 '25 20:12

Spacedman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!