How to display/show Static HTML file in apache superset? - apache-superset

Have a couple of static HTML files and would like to display
them in Apache Superset.
Is there an easy way (vs modifying the code).

Related

How can I serve a stand-alone static app through Django

We're using django for authentication, user management, site content etc, but we have a JS tool that needs to be behind django auth as well. The tool is an html page that pulls in a couple dozen static files through relative paths in the html page (src="./someJSfile.js").
The problem is I can't figure out how to serve the html file through django but keep the relative paths intact. I can create an apache alias to that directory so that the relative paths are intact, but then the html is served through apache and bypasses auth. I would like to be able to have the html file served through a django view so that auth works, and also keep the static files in the same directory.
Is there some apache magic where I can have the html served through django but have the static served through apache using an alias, while keeping the html and static in the same directory?
Thanks in advance

Access static content of extjs production build in Django static path

I am facing problem with static content such as .png, .jpg files in Django+extjs environment.
I develop my client side in Extjs with sencha environment and test it locally with sencha server (sencha app watch) which works fine and I see the static images on the UI page.
Now I take a production build of that app (sencha app build classic).
It generates two folders.
Classic : This has app.js and CSS,fonts etc...
resources : (Here is the problem) This has static files like images and json files(if any)
Now I copy these two folders to my Django static path and access the app.js and and CSS files from Django's HTML template. This works.
However, The problem is Django is unable to locate the image files that are there in resources folder (mentioned in list item 2).
If the URL is 'localhost:81/app_name', it searches for the images in the below path
localhost:81/app_name/resources/images/abc.png
But is should look in the below path to get these files
localhost:81/static/resources/images/abc.png
What am i missing here? How Do I tell Django/Extjs to search for the static content in localhost:81/static/resources/images/abc.png
Please suggest.

Content negotiation with Django staticfiles in runserver

I'm managing static files (JS, CSS, images, etc) in my Django application using staticfiles. This works fine, but I'd like to start dynamically serving pre-compressed sources when the user's browser is capable.
I went through the linked tutorial and, in production (on Apache) this works fine. I can include files using
<script src="/static/js/my-site"></script>
and it will load my-site.js in older browsers and my-site.js.gz when GZip encoding is supported. Great! But: this breaks local development using runserver. Of course, the staticfiles default view has no idea how to turn /js/my-site into /js/my-site.js (or .gz). To get runserver working, I need to specify the extension, which breaks content negotiation.
Is there a better way to configure Apache, so that I can always request .js (or .css, etc) and get served the compressed version transparently? Or can I tell Django how to find the requested resource without specifying an extension? I wouldn't think I'm the only one trying to do this...
there is no simple resolution. mostly because you are using something that was designed for the apache web server only (afaik).
i my opinion there are 3 solutions:
keep source .{js,css} files in separate directory, in development you can serve them from source dir or compressed one - simple, transparent and you can hide your uncompressed and non-obfuscated sources far from the reach
compress files with the .min.{js,css} ending - no need for separate directory, you can hide sources in apache (mod_rewrite)
write your own small middleware that will be simulating what apache does (it is few lines to select and rewrite path, you can even have different behavior depending on DEBUG config var)
use some dynamic solution e.g Django Compressor which will compile those files on-demand
(I'm using option 4 :) )

How to include a small and lightweight standalone application inside a web page in django?

I need to add a currency converter and a calculator to my website that runs on the client side.
something similar to a servlet in java.
Adding a client-side "whatever" to a django project is no different than adding an image, or a video, or anything else. Django doesn't particularly care what you put into your templates. It simply renders the templates server-side to parse your template language code, and then serves up a normal web page to the client.
So the answer to your question is... Do whatever you would normally do in an html page to embed your chosen solution into the page.
The only django-specific issues here could be how to source the path to the media using template tags, which is also no different than sourcing static content like images, javascript, and css. You can read more about that on the django docs: Managing static files

Django where to put static files

I am using Django to create a small web app, however I do not know where i must put my HTML and JS files. I don't want to use the templateing system because I have no need to pass the values from Django directly to the HTML template, Instead the HTML will be static and I will fetch all the data necessary and send the data to be input back into the database using AJAX with Jquery.
My Question is where must I put my HTMl and JS files so they are accessible from the web browser and will be in the same directory so that I can send my ajax requests to something like
http://localhost:2000/webapp/RPC/updateitem/ (more stuff here)
and where the HTML files are
http://localhost:2000/webapp/index.html
Thanks,
RayQuang
You let your main webserver (the one you're running django on) deal with the static files. In most cases this means that you simly server the files through apache (or lighttpd or cherrypy or whatever). Django is only ment for the rendering of dynamic things and thus should not be used for serving static files.
If you're running from a development server (which I can't recommend), this tutorial will help you through setting it up: Serving static files