Browser storage IndexedDB can be used for storing static files like css and some js file? - offline

I want to made offline first web application.
If a network is not available then data and css files should be load from indexedDB.
I may be wrong or this requirement look like weird but want to know that is it possible or not?
I don't want to go with service worker and app cache options.
Thanks in advance.

You are gonna need service worker to make offline first web application.
You can use indexdb instead of cache.

Related

Whats a good pattern for a web-application for serving files?

I am working on an angular Web-Application where it's possible to view pdf-files in a pdf-viewer in the browser.
The Web-Application is also consuming a REST-Service in Django.
In the Database the information of the pdf-files is stored. The Web-App is calling the REST-API to check where the files are stored.
As I am still in the Proof-Of-Concept Phase of the project, the PDF-Files are currently stored in the assets folder of the angular web, which of course is not what I want in the end.
When the Files or the Directories change, the Database should be updated automatically (or via a trigger in the app).
I have two questions:
Is there an obvious way to serve the files in this combination? i.e. an apache server? I imagine there are built in solutions in dedicated file servers to detect changes of the watched directory.
For a partly solution would it be reasonable to write a script on the django site, which does the file-serving, the updating and also providing the REST-API?

How to define URLs only once for server and client?

everyone! I am building a web application, i.e. a server-client application. For the interaction between the two, I have to define the URLs twice (hard-coded strings), both on the backend and the frontend, which makes future changes hard, because it would require changing the code in two places, rather than just one.
I am using Django and Angular and so I am looking for a way to specify the back end endpoints once, then ideally read them and use them for the Angular production build. Therefore changes to the endpoints will only require a new build, but no further changes.
Should these be defined in some .cfg file and be read by the back end on server startup and maybe somehow add them to the Angular's build process? Any suggestion would help because this redundancy comes in almost every webapp project and there has to be a more clever solution!
Thanks for the help in advance!
Here, it is the backend application that owns and defines url mappings to entities. It is possible that multiple clients can consume from the same API, like a web client, an Android client and an iOS client. In this setup, your backend is the point of truth for the url mappings, and client applications should be configured to use the url mappings defined in the backend application.
One possible way to do this is to serve defined urls in the backend on a path of the backend application, and have your client applications configure themselves using the data provided there. For example, if you use Django Rest Framework, by default, on the root path of the API ("/"), resources along with url mappings for the resources are served. You can use such a mechanism to configure your client applications on build time.
How many endpoints and how likely are you to alter them? Most likely you will always have to make more changes than just in 1 place as the reason behind changing an endpoint is normally you are trying to POST or GET new data structures. This would mean you will have to alter that request process anyway to handle the new data type or what was being posted.
Also, consider some of the publicly available api's out there - they don't give you an endpoint that serves a config file of available routes. When they make a change to their endpoints they usually create a versioned api so that consumers can upgrade in their own time.
In my opinion, unless you are planning a large scale web app, I wouldn't be too worried about trying to implement something like this.

Django views that are inaccessible publicly but accessibly internally?

I have a few views I want to expose to apps internal to the server cluster. How can I do this securely?
The apps that want to access these restricted views are also using python, so if I can arguably bypass the HTTP tunneling and call directly to them, that's even better. I think these would be better suited as commands if that's the case, but how can another process invoke a Django environment's commands?
Once you load the project's settings you can act as the project itself.
It sounds like you basically want to extract some data from your Django site and use it elsewhere. Perhaps a couple of management commands that periodically output their data in some directory which you can then read from the other python apps? Depends on your data needs whether that's an option.
I'm doing this suggestion as those other apps seem to be on the same server (how could you otherwise run your site's python code from those apps?).

Django : open application on client station

I would like to ask a relatively simple question in which I didn't put much thought in yet. But I'd just like to know if this is possible before starting painful implementations of my app!
Here it is : Is it possible (and easy..) to run an application and communicate with files on the client's computer from a web application developped in Django ?
I'd really just like to know if it's feasible. Of course if you have a few hints on how to do it, they would be appreciated :)
Yes, it's perfectly possible to do that. You just need to add a proper URL with its corresponding view, processing your HTTP request from client machines and interacting with local files as you need.
Key thing here is to use a proper HttpClient on the machine accessing your client's file.

HTML5 Offline storage web framework

I am looking for a web app framework which can automatically generate an HTML5 offline storage based app, so while the users become disconnected they still can view the data which normally is stored on a server
Also currently I am using Django and it would be great if there was a framework which could pull data from Django and present that as an offline app.
From the related questions suggested by stackoverflow, while writing this question, I found one interesting link mentioning that GWT has such functionality, I would like to know more about that if possible and if it can generate an HTML5 offline app
Thanks in Advance
Rather than server-side frameworks, you should be taking a look at JavaScript frameworks.
Dojo Storage will transparently select between providers such as Google Gears, Adobe AIR or plain old HTML 5 local storage. Dojo 1.5 - dojox.storage: http://dojotoolkit.org/api/1.5/dojox/storage
There's also jQuery local storage: http://plugins.jquery.com/project/saveit
... or jStorage, which can act as a storage plugin for jQuery, Prototype or MooTools: http://www.jstorage.info/
With any of these, you should be able to use a quick little AJAX call to pull (JSON perhaps) data from your server and use one of these tools to help minimise your storage code.
You're talking about a standalone app, not a django app.
This can be done with javascript (jQuery, Sproutcore, JavascriptMVC, Pyjamas ...) or Adobe AIR, or...
Pulling data from Django is just a matter of setting up a syncing method, most probably using JSON, to fill up the browser local storage. So this is not django-specific at all.
If you want a standalone django app, this can be done if you bundle in a python desktop app django with a built-in server, that's another question
You could suggest the users to create web apps or use google gears instead... I don't know if this will fill the question, but, i'm in the same way. However, I'm developing an governamental solution who will run only for some kind of people, so, I can have a few control about the user's environment... All you need to do is to use jquery to detect if user has a live connection, or offer to the users a 'preferences' page where you define the behavior of the page itself...
Some info about offline cache: http://diveintohtml5.ep.io/offline.html
PS.: In another post in stackoverflow, I 've found another question: html5 offline caching with php driven sites... The last Post said:
HTML5 offline caching does not work to make your pages interact; it works only to make a
particular page available offline. Basically, it works on a URL-by-URL basis. If you
absolutely need offline functionality, you will be forced to make it work in JS.
Also, make sure your manifest includes all resources used by all pages.
Hope this helps!
Hope it helps!!