Monday, February 8, 2016

Re: How to show python data on html


On Sun, Feb 7, 2016 at 11:15 AM, 123asror <asrorwali7@gmail.com> wrote:
So currently i have a python console application that reads from an api and print some data i want. I followed the django course and they use models/database in it. The data that they show comes from that. So i was wondering how to add a html page to my console application or python code. Is there a tutorial i can follow for that ?

- Do you just want to save the data you're receiving in an HTML file?

If so, you're better off just using a template library (jinja or other), there's no need for an entire framework to do this.

- Do you want to serve the data so that it's accessible through a browser?

If so, then yes you could use django for this purpose. Django isn't limited to fetching data from the database, it's primary job is to enable you to serve content. You have content, you want to deliver this content, django is for you.

- Is your console application short running? Does it do it's job, print the content and then exit?

If so, you can just invoke the application from within a django view. However, if the operation isn't very fast, you may want to reach out to a task queue, but you really should worry about this in due time.

- Is your console application long running? Does it fetch data constantly?

Then you'll need to decide on how to make content available for your django application to serve. One of the ways you could do this is have your application send the data to a medium and have django read from that medium. Possibly store in files, in the database, in a queue or some other place, then django could read from there.

- Do you plan on delivering the content in realtime as you receive it?

If so, I'd suggest placing this as a different phase of implementation, but some keywords for you to look for if you ever get to that point: javascript polling, websockets, tornado, gevent, socket.io...

-

Good luck.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFwtXp218gZduKLw4GQM5CnTYK5385Kg%3DvygPo5dC7TvG%2BCDSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment