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 <[email protected]> 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 <[email protected]> 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
>>
>

Reply via email to