flask - How to detect a small screen? - flask

What is the best practice to detect small screens with flask ? Is there an alternative of using a JS script doing the job and then communicating it via a route to flask ?

The server does not know anything about the window the browser is running in. You will need to use javascript.

Related

How to make vue js ssr using the django framework

I want to make some part of my application capable of supporting server rendering. In the project, we actively use vuex and vue router.
We receive all data using api requests
Tell me where to go or provide any working code snippet.
Thank you in advance
An example of an answer might be this. You are creating a fully isolated SPA application with SSR. Django acts only as an API for your application (including you will need to receive data for INITIAL_STATE by API). Next, you start your NodeJs server on any port. Next, you need to configure nginx for redirect requests from port 80 for specific routes to the port of your application.
This is just a theory. Until hands reached a full-fledged example

How to Convert python Tkinter desktop App to Web App

I have wrote python(2.7) GUI desktop application using TKinter library and it is working fine. Now i want to convert it into web application. I have looked into pyjaco and pyjamas but not getting it done.
How can i convert it into Web App ?
Thanks in advance..
You will have to rewrite your app. There is simply no way to convert a tkinter application to run on the web. You could potentially use pyjs to convert some of the business logic, but the entire GUI will have to be rewritten.
You can use CloudTk.
CloudTk is based on WebSockit2me - a TCP to WebSocket gateway that uses a noVNC to display Tk applications in modern Web Browser.

Cloning PyQt app in django framework

I've designed a desktop app using PyQt GUI toolkit and now I need to embed this app on my Django website. Do I need to clone it using django's own logic or is there a way to get it up on website using some interface. Coz I need this to work on my website same way it works as desktop. Do I need to find out packages in django to remake it over the web or is there way to simplify the task?
Please help.
I'm not aware of any libraries to port a PyQT desktop app to a django webapp. Django certainly does nothing to enable this one way or another. I think, you'll find that you have to rewrite it for the web. Django is a great framework and depending on the complexity of your app, it might not be too difficult. If you haven't done much with web development, there is a lot to learn!
If it seemed like common sense to you that you should be able to run a desktop app as a webapp, consider this:
Almost all web communication that you likely encounter is done via HTTP. HTTP is a protocol for passing data between servers and clients (often, browsers). What this means is that any communication that takes place must be resolved into discrete chunks. Consider an example flow:
You go to google in your browser.
Your browser then hits a DNS server (or cache) that resolves the name google.com to some IP address.
Cool, now your browser makes a request to that IP address and says "get me some stuff".
Google decides to send you back a minimal amount of HTML and lots of minified JavaScript in the page.
Your browser realizes that there are some image links in the HTML and so it makes additional requests to google to get each of the images so that it can display them.
Now all the content is loaded on your browser so it starts to execute the JavaScript code, and that code needs some more data from google so it starts sending requests to google too.
This is just a small example of how fundamentally different a web application operates than how a desktop application does. On a desktop app you have the added convenience that any operation doesn't need to be "packaged up" and sent, then have an action taken, etc (unless you're using a messaging architecture, but that's relatively uncommon outside of enterprise apps).

Apache/wsgi/django configuration

We have two django applications running on the same server that interact with an API that uses oauth. They function as expected, communicating with each other, when run under the django development server. However, when deployed using apache/wsgi they don't work together.
(To be more specific, one application is an instance of the Indivo server; the other one is a custom application that interacts with Indivo.)
What is the best way to trouble shoot this?
Make sure that the Django instances are working by themselves first. For example, one app could be started under Apache, and the other using ./manage.py runserver. Reverse which one is running using Apache and verify that all works as expected.
Use the Apache error logs to look for errors such as failed requests.
Since one of your apps appears to implement a web API, use something like the Google Chrome Postman App to exercise the site from a web browser.
Learn how to use the Django logging framework to log information about your apps as they execute.

Accessing a django-piston REST API via a django view within the same project

I'm building a small web service. To showcase what the service can do I am going to build a lite-weight interface. I'm having a hard time figuring out how my REST API and regular Django views can play nicely together.
Here's my setup:
Using django-piston to build a simple CRUD REST web service.
Using Django views with httplib2 to GET/POST to/from that web service.
Both are being run from the same Django project (and thus same web server).
Right now I have simple read REST service working in the browser. But when I try to use httplib2 from the Django view the request just hangs.
My questions:
-Am I thinking about this the right way?
-Is there a better way to accomplish this?
-Should my REST web service be a different project (and web server) than my REST interface?
Any help would be greatly appreciated!
Generally, I'd demonstrate an API working via unit tests, rather than live views, but can see how that might not be what you need.
So (in line with akonsu's comment above) if you're experiencing this problem local dev, it's the single threaded devserver that's blocking the API from running while the view is executing.
Have you tried a multi-threaded version of the runserver? Like this one?