You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@zeppelin.apache.org by Randy Gelhausen <rg...@gmail.com> on 2015/08/17 06:15:15 UTC

static asset folder?

Does Zeppelin Server have the capability to serve static files from a
directory?

For instance, if I want a Notebook to import HTML and JS files which are
not hosted anywhere externally, is there a way to have Zeppelin itself host
those without recompiling and building the static assets into the JAR?

Thanks,
-Randy

Re: static asset folder?

Posted by Randy Gelhausen <rg...@gmail.com>.
 https://issues.apache.org/jira/browse/ZEPPELIN-225 created

On Mon, Aug 17, 2015 at 12:26 AM, Corneau Damien <co...@gmail.com>
wrote:

> Hi,
>
> To bypass the zeppelin-web ressources restriction, you could also open and
> read file from scala,
> and printing its content using println("%html " + fileContent)
>
> On Mon, Aug 17, 2015 at 1:41 PM, moon soo Lee <mo...@apache.org> wrote:
>
>> Hi Randy,
>>
>> The answer is no.
>>
>> However, depending on how you build and run Zeppelin, there is on trick.
>> If you build and run Zeppelin directly from source, Zeppelin serves it's
>> web resources from zeppelin-web/dist directory rather than packaged war
>> file.
>>
>> Here's one example that uses this trick. This example generates download
>> link from data frame. Note that, this trick is not working on packaged
>> distribution of Zeppelin (which is reading single war file instead of
>> looking for dist directory).
>>
>> def saveAsCsv(df:org.apache.spark.sql.DataFrame, fileName:String,
>> num:Int) {
>> // create dir (ZEPPELIN_HOME/zeppelin-web/dist/data)
>> val conf = org.apache.zeppelin.conf.ZeppelinConfiguration.create()
>> val basePath =
>> conf.getString(org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars.ZEPPELIN_WAR)
>> new java.io.File(basePath + "/data").mkdirs()
>>
>>
>> // create file
>> val file = new java.io.File(basePath + "/data/" + fileName)
>> val p = new java.io.PrintWriter(file)
>> try {
>> // write csv header
>> p.println(df.schema.map(s=>s.name(0)).mkString(","))
>> // write rows
>> df.take(num).map(r=>r.mkString(",")).foreach(p.println _)
>>
>> // print download link
>>
>> println(s"""%html Download <a href="/data/$fileName" download
>> target="_blank">$fileName</a>""")
>> } finally {
>> // close file
>> p.close()
>> }
>> }
>>
>>
>> It'll be great If you could create an issue for having capability to
>> serve static file for both packaged version and source build.
>>
>> Best,
>> moon
>>
>> On Sun, Aug 16, 2015 at 9:15 PM Randy Gelhausen <rg...@gmail.com>
>> wrote:
>>
>>> Does Zeppelin Server have the capability to serve static files from a
>>> directory?
>>>
>>> For instance, if I want a Notebook to import HTML and JS files which are
>>> not hosted anywhere externally, is there a way to have Zeppelin itself host
>>> those without recompiling and building the static assets into the JAR?
>>>
>>> Thanks,
>>> -Randy
>>>
>>
>

Re: static asset folder?

Posted by Corneau Damien <co...@gmail.com>.
Hi,

To bypass the zeppelin-web ressources restriction, you could also open and
read file from scala,
and printing its content using println("%html " + fileContent)

On Mon, Aug 17, 2015 at 1:41 PM, moon soo Lee <mo...@apache.org> wrote:

> Hi Randy,
>
> The answer is no.
>
> However, depending on how you build and run Zeppelin, there is on trick.
> If you build and run Zeppelin directly from source, Zeppelin serves it's
> web resources from zeppelin-web/dist directory rather than packaged war
> file.
>
> Here's one example that uses this trick. This example generates download
> link from data frame. Note that, this trick is not working on packaged
> distribution of Zeppelin (which is reading single war file instead of
> looking for dist directory).
>
> def saveAsCsv(df:org.apache.spark.sql.DataFrame, fileName:String, num:Int)
> {
> // create dir (ZEPPELIN_HOME/zeppelin-web/dist/data)
> val conf = org.apache.zeppelin.conf.ZeppelinConfiguration.create()
> val basePath =
> conf.getString(org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars.ZEPPELIN_WAR)
> new java.io.File(basePath + "/data").mkdirs()
>
>
> // create file
> val file = new java.io.File(basePath + "/data/" + fileName)
> val p = new java.io.PrintWriter(file)
> try {
> // write csv header
> p.println(df.schema.map(s=>s.name(0)).mkString(","))
> // write rows
> df.take(num).map(r=>r.mkString(",")).foreach(p.println _)
>
> // print download link
>
> println(s"""%html Download <a href="/data/$fileName" download
> target="_blank">$fileName</a>""")
> } finally {
> // close file
> p.close()
> }
> }
>
>
> It'll be great If you could create an issue for having capability to serve
> static file for both packaged version and source build.
>
> Best,
> moon
>
> On Sun, Aug 16, 2015 at 9:15 PM Randy Gelhausen <rg...@gmail.com> wrote:
>
>> Does Zeppelin Server have the capability to serve static files from a
>> directory?
>>
>> For instance, if I want a Notebook to import HTML and JS files which are
>> not hosted anywhere externally, is there a way to have Zeppelin itself host
>> those without recompiling and building the static assets into the JAR?
>>
>> Thanks,
>> -Randy
>>
>

Re: static asset folder?

Posted by moon soo Lee <mo...@apache.org>.
Hi Randy,

The answer is no.

However, depending on how you build and run Zeppelin, there is on trick.
If you build and run Zeppelin directly from source, Zeppelin serves it's
web resources from zeppelin-web/dist directory rather than packaged war
file.

Here's one example that uses this trick. This example generates download
link from data frame. Note that, this trick is not working on packaged
distribution of Zeppelin (which is reading single war file instead of
looking for dist directory).

def saveAsCsv(df:org.apache.spark.sql.DataFrame, fileName:String, num:Int) {
// create dir (ZEPPELIN_HOME/zeppelin-web/dist/data)
val conf = org.apache.zeppelin.conf.ZeppelinConfiguration.create()
val basePath =
conf.getString(org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars.ZEPPELIN_WAR)
new java.io.File(basePath + "/data").mkdirs()


// create file
val file = new java.io.File(basePath + "/data/" + fileName)
val p = new java.io.PrintWriter(file)
try {
// write csv header
p.println(df.schema.map(s=>s.name(0)).mkString(","))
// write rows
df.take(num).map(r=>r.mkString(",")).foreach(p.println _)

// print download link

println(s"""%html Download <a href="/data/$fileName" download
target="_blank">$fileName</a>""")
} finally {
// close file
p.close()
}
}


It'll be great If you could create an issue for having capability to serve
static file for both packaged version and source build.

Best,
moon

On Sun, Aug 16, 2015 at 9:15 PM Randy Gelhausen <rg...@gmail.com> wrote:

> Does Zeppelin Server have the capability to serve static files from a
> directory?
>
> For instance, if I want a Notebook to import HTML and JS files which are
> not hosted anywhere externally, is there a way to have Zeppelin itself host
> those without recompiling and building the static assets into the JAR?
>
> Thanks,
> -Randy
>