import{S as ta,i as oa,s as aa,e as a,k as p,w as Zt,t as l,N as ia,c as i,d as t,m as u,a as s,x as eo,h as r,b as f,P as ea,G as o,g as h,y as to,L as sa,q as oo,o as ao,B as io,v as la}from"../chunks/vendor-hf-doc-builder.js";import{I as so}from"../chunks/IconCopyLink-hf-doc-builder.js";function ra(lo){let w,ke,g,S,ie,R,Xe,se,Ze,Pe,x,A,et,tt,Te,B,ot,Re,_,k,le,$,at,re,it,xe,D,H,st,lt,Ae,J,rt,$e,F,ne,ro,De,z,he,nt,He,d,ht,N,ft,pt,I,ut,ct,Fe,Q,fe,yt,Ne,V,mt,Ie,X,pe,dt,Me,Z,vt,qe,b,P,ue,M,wt,ce,gt,Ce,y,q,_t,bt,C,Et,St,G,kt,Pt,L,Tt,Rt,Ge,ee,xt,Le,O,ye,no,Oe,m,me,At,$t,de,Dt,Ht,ve,Ft,Nt,Ue,te,we,It,Ye,c,Mt,U,qt,Ct,Y,Gt,Lt,ge,Ot,Ut,_e,Yt,jt,je,oe,Kt,Ke,T,be,Ee,Wt,Bt,Se,j,Jt,K,zt,Qt,We;return R=new so({}),$=new so({}),M=new so({}),{c(){w=a("meta"),ke=p(),g=a("h1"),S=a("a"),ie=a("span"),Zt(R.$$.fragment),Xe=p(),se=a("span"),Ze=l("Shiny on Spaces"),Pe=p(),x=a("p"),A=a("a"),et=l("Shiny"),tt=l(` is an open-source framework for building simple, beautiful, and performant data applications.
The goal when developing Shiny was to build something simple enough to teach someone in an afternoon but extensible enough to power large, mission-critical applications.
You can create a useful Shiny app in a few minutes, but if the scope of your project grows, you can be sure that Shiny can accommodate that application.`),Te=p(),B=a("p"),ot=l(`The main feature that differentiates Shiny from other frameworks is its reactive execution model.
When you write a Shiny app, the framework infers the relationship between inputs, outputs, and intermediary calculations and uses those relationships to render only the things that need to change as a result of a user\u2019s action.
The result is that users can easily develop efficient, extensible applications without explicitly caching data or writing callback functions.`),Re=p(),_=a("h2"),k=a("a"),le=a("span"),Zt($.$$.fragment),at=p(),re=a("span"),it=l("Shiny for Python"),xe=p(),D=a("p"),H=a("a"),st=l("Shiny for Python"),lt=l(` is a pure Python implementation of Shiny.
This gives you access to all of the great features of Shiny like reactivity, complex layouts, and modules without needing to use R.
Shiny for Python is ideal for Hugging Face applications because it integrates smoothly with other Hugging Face tools.`),Ae=p(),J=a("p"),rt=l(`To get started deploying a Space, click this button to select your hardware and specify if you want a public or private Space.
The Space template will populate a few files to get your app started.`),$e=p(),F=a("a"),ne=a("img"),De=p(),z=a("p"),he=a("em"),nt=l("app.py"),He=p(),d=a("p"),ht=l("This file defines your app\u2019s logic. To learn more about how to modify this file, see "),N=a("a"),ft=l("the Shiny for Python documentation"),pt=l(`.
As your app gets more complex, it\u2019s a good idea to break your application logic up into `),I=a("a"),ut=l("modules"),ct=l("."),Fe=p(),Q=a("p"),fe=a("em"),yt=l("Dockerfile"),Ne=p(),V=a("p"),mt=l(`The Dockerfile for a Shiny for Python app is very minimal because the library doesn\u2019t have many system dependencies, but you may need to modify this file if your application has additional system dependencies.
The one essential feature of this file is that it exposes and runs the app on the port specified in the space README file (which is 7860 by default).`),Ie=p(),X=a("p"),pe=a("strong"),dt=l("requirements.txt"),Me=p(),Z=a("p"),vt=l(`The Space will automatically install dependencies listed in the requirements.txt file.
Note that you must include shiny in this file.`),qe=p(),b=a("h2"),P=a("a"),ue=a("span"),Zt(M.$$.fragment),wt=p(),ce=a("span"),gt=l("Shiny for R"),Ce=p(),y=a("p"),q=a("a"),_t=l("Shiny for R"),bt=l(" is a popular and well-established application framework in the R community and is a great choice if you want to host an R app on Hugging Face infrastructure or make use of some of the great "),C=a("a"),Et=l("Shiny R extensions"),St=l(`.
To integrate Hugging Face tools into an R app, you can either use `),G=a("a"),kt=l("httr2"),Pt=l(" to call Hugging Face APIs, or "),L=a("a"),Tt=l("reticulate"),Rt=l(" to call one of the Hugging Face Python SDKs."),Ge=p(),ee=a("p"),xt=l(`To deploy an R Shiny Space, click this button and fill out the space metadata.
This will populate the Space with all the files you need to get started.`),Le=p(),O=a("a"),ye=a("img"),Oe=p(),m=a("p"),me=a("em"),At=l("app.R"),$t=l(`
This file contains all of your application logic. If you prefer, you can break this file up into `),de=a("code"),Dt=l("ui.R"),Ht=l(" and "),ve=a("code"),Ft=l("server.R"),Nt=l("."),Ue=p(),te=a("p"),we=a("em"),It=l("Dockerfile"),Ye=p(),c=a("p"),Mt=l("The Dockerfile builds off of the the "),U=a("a"),qt=l("rocker shiny"),Ct=l(` image. You\u2019ll need to modify this file to use additional packages.
If you are using a lot of tidyverse packages we recommend switching the base image to `),Y=a("a"),Gt=l("rocker/shinyverse"),Lt=l(`.
You can install additional R packages by adding them under the `),ge=a("code"),Ot=l("RUN install2.r"),Ut=l(" section of the dockerfile, and github packages can be installed by adding the repository under "),_e=a("code"),Yt=l("RUN installGithub.r"),jt=l("."),je=p(),oe=a("p"),Kt=l("There are two main requirements for this Dockerfile:"),Ke=p(),T=a("ul"),be=a("li"),Ee=a("p"),Wt=l("First, the file must expose the port that you have listed in the README. The default is 7860 and we recommend not changing this port unless you have a reason to."),Bt=p(),Se=a("li"),j=a("p"),Jt=l("Second, for the moment you must use the development version of "),K=a("a"),zt=l("httpuv"),Qt=l(" which resolves an issue with app timeouts on Hugging Face."),this.h()},l(e){const n=ia('[data-svelte="svelte-1phssyn"]',document.head);w=i(n,"META",{name:!0,content:!0}),n.forEach(t),ke=u(e),g=i(e,"H1",{class:!0});var Be=s(g);S=i(Be,"A",{id:!0,class:!0,href:!0});var ho=s(S);ie=i(ho,"SPAN",{});var fo=s(ie);eo(R.$$.fragment,fo),fo.forEach(t),ho.forEach(t),Xe=u(Be),se=i(Be,"SPAN",{});var po=s(se);Ze=r(po,"Shiny on Spaces"),po.forEach(t),Be.forEach(t),Pe=u(e),x=i(e,"P",{});var Vt=s(x);A=i(Vt,"A",{href:!0,rel:!0});var uo=s(A);et=r(uo,"Shiny"),uo.forEach(t),tt=r(Vt,` is an open-source framework for building simple, beautiful, and performant data applications.
The goal when developing Shiny was to build something simple enough to teach someone in an afternoon but extensible enough to power large, mission-critical applications.
You can create a useful Shiny app in a few minutes, but if the scope of your project grows, you can be sure that Shiny can accommodate that application.`),Vt.forEach(t),Te=u(e),B=i(e,"P",{});var co=s(B);ot=r(co,`The main feature that differentiates Shiny from other frameworks is its reactive execution model.
When you write a Shiny app, the framework infers the relationship between inputs, outputs, and intermediary calculations and uses those relationships to render only the things that need to change as a result of a user\u2019s action.
The result is that users can easily develop efficient, extensible applications without explicitly caching data or writing callback functions.`),co.forEach(t),Re=u(e),_=i(e,"H2",{class:!0});var Je=s(_);k=i(Je,"A",{id:!0,class:!0,href:!0});var yo=s(k);le=i(yo,"SPAN",{});var mo=s(le);eo($.$$.fragment,mo),mo.forEach(t),yo.forEach(t),at=u(Je),re=i(Je,"SPAN",{});var vo=s(re);it=r(vo,"Shiny for Python"),vo.forEach(t),Je.forEach(t),xe=u(e),D=i(e,"P",{});var Xt=s(D);H=i(Xt,"A",{href:!0,rel:!0});var wo=s(H);st=r(wo,"Shiny for Python"),wo.forEach(t),lt=r(Xt,` is a pure Python implementation of Shiny.
This gives you access to all of the great features of Shiny like reactivity, complex layouts, and modules without needing to use R.
Shiny for Python is ideal for Hugging Face applications because it integrates smoothly with other Hugging Face tools.`),Xt.forEach(t),Ae=u(e),J=i(e,"P",{});var go=s(J);rt=r(go,`To get started deploying a Space, click this button to select your hardware and specify if you want a public or private Space.
The Space template will populate a few files to get your app started.`),go.forEach(t),$e=u(e),F=i(e,"A",{href:!0});var _o=s(F);ne=i(_o,"IMG",{src:!0}),_o.forEach(t),De=u(e),z=i(e,"P",{});var bo=s(z);he=i(bo,"EM",{});var Eo=s(he);nt=r(Eo,"app.py"),Eo.forEach(t),bo.forEach(t),He=u(e),d=i(e,"P",{});var ae=s(d);ht=r(ae,"This file defines your app\u2019s logic. To learn more about how to modify this file, see "),N=i(ae,"A",{href:!0,rel:!0});var So=s(N);ft=r(So,"the Shiny for Python documentation"),So.forEach(t),pt=r(ae,`.
As your app gets more complex, it\u2019s a good idea to break your application logic up into `),I=i(ae,"A",{href:!0,rel:!0});var ko=s(I);ut=r(ko,"modules"),ko.forEach(t),ct=r(ae,"."),ae.forEach(t),Fe=u(e),Q=i(e,"P",{});var Po=s(Q);fe=i(Po,"EM",{});var To=s(fe);yt=r(To,"Dockerfile"),To.forEach(t),Po.forEach(t),Ne=u(e),V=i(e,"P",{});var Ro=s(V);mt=r(Ro,`The Dockerfile for a Shiny for Python app is very minimal because the library doesn\u2019t have many system dependencies, but you may need to modify this file if your application has additional system dependencies.
The one essential feature of this file is that it exposes and runs the app on the port specified in the space README file (which is 7860 by default).`),Ro.forEach(t),Ie=u(e),X=i(e,"P",{});var xo=s(X);pe=i(xo,"STRONG",{});var Ao=s(pe);dt=r(Ao,"requirements.txt"),Ao.forEach(t),xo.forEach(t),Me=u(e),Z=i(e,"P",{});var $o=s(Z);vt=r($o,`The Space will automatically install dependencies listed in the requirements.txt file.
Note that you must include shiny in this file.`),$o.forEach(t),qe=u(e),b=i(e,"H2",{class:!0});var ze=s(b);P=i(ze,"A",{id:!0,class:!0,href:!0});var Do=s(P);ue=i(Do,"SPAN",{});var Ho=s(ue);eo(M.$$.fragment,Ho),Ho.forEach(t),Do.forEach(t),wt=u(ze),ce=i(ze,"SPAN",{});var Fo=s(ce);gt=r(Fo,"Shiny for R"),Fo.forEach(t),ze.forEach(t),Ce=u(e),y=i(e,"P",{});var E=s(y);q=i(E,"A",{href:!0,rel:!0});var No=s(q);_t=r(No,"Shiny for R"),No.forEach(t),bt=r(E," is a popular and well-established application framework in the R community and is a great choice if you want to host an R app on Hugging Face infrastructure or make use of some of the great "),C=i(E,"A",{href:!0,rel:!0});var Io=s(C);Et=r(Io,"Shiny R extensions"),Io.forEach(t),St=r(E,`.
To integrate Hugging Face tools into an R app, you can either use `),G=i(E,"A",{href:!0,rel:!0});var Mo=s(G);kt=r(Mo,"httr2"),Mo.forEach(t),Pt=r(E," to call Hugging Face APIs, or "),L=i(E,"A",{href:!0,rel:!0});var qo=s(L);Tt=r(qo,"reticulate"),qo.forEach(t),Rt=r(E," to call one of the Hugging Face Python SDKs."),E.forEach(t),Ge=u(e),ee=i(e,"P",{});var Co=s(ee);xt=r(Co,`To deploy an R Shiny Space, click this button and fill out the space metadata.
This will populate the Space with all the files you need to get started.`),Co.forEach(t),Le=u(e),O=i(e,"A",{href:!0});var Go=s(O);ye=i(Go,"IMG",{src:!0}),Go.forEach(t),Oe=u(e),m=i(e,"P",{});var W=s(m);me=i(W,"EM",{});var Lo=s(me);At=r(Lo,"app.R"),Lo.forEach(t),$t=r(W,`
This file contains all of your application logic. If you prefer, you can break this file up into `),de=i(W,"CODE",{});var Oo=s(de);Dt=r(Oo,"ui.R"),Oo.forEach(t),Ht=r(W," and "),ve=i(W,"CODE",{});var Uo=s(ve);Ft=r(Uo,"server.R"),Uo.forEach(t),Nt=r(W,"."),W.forEach(t),Ue=u(e),te=i(e,"P",{});var Yo=s(te);we=i(Yo,"EM",{});var jo=s(we);It=r(jo,"Dockerfile"),jo.forEach(t),Yo.forEach(t),Ye=u(e),c=i(e,"P",{});var v=s(c);Mt=r(v,"The Dockerfile builds off of the the "),U=i(v,"A",{href:!0,rel:!0});var Ko=s(U);qt=r(Ko,"rocker shiny"),Ko.forEach(t),Ct=r(v,` image. You\u2019ll need to modify this file to use additional packages.
If you are using a lot of tidyverse packages we recommend switching the base image to `),Y=i(v,"A",{href:!0,rel:!0});var Wo=s(Y);Gt=r(Wo,"rocker/shinyverse"),Wo.forEach(t),Lt=r(v,`.
You can install additional R packages by adding them under the `),ge=i(v,"CODE",{});var Bo=s(ge);Ot=r(Bo,"RUN install2.r"),Bo.forEach(t),Ut=r(v," section of the dockerfile, and github packages can be installed by adding the repository under "),_e=i(v,"CODE",{});var Jo=s(_e);Yt=r(Jo,"RUN installGithub.r"),Jo.forEach(t),jt=r(v,"."),v.forEach(t),je=u(e),oe=i(e,"P",{});var zo=s(oe);Kt=r(zo,"There are two main requirements for this Dockerfile:"),zo.forEach(t),Ke=u(e),T=i(e,"UL",{});var Qe=s(T);be=i(Qe,"LI",{});var Qo=s(be);Ee=i(Qo,"P",{});var Vo=s(Ee);Wt=r(Vo,"First, the file must expose the port that you have listed in the README. The default is 7860 and we recommend not changing this port unless you have a reason to."),Vo.forEach(t),Qo.forEach(t),Bt=u(Qe),Se=i(Qe,"LI",{});var Xo=s(Se);j=i(Xo,"P",{});var Ve=s(j);Jt=r(Ve,"Second, for the moment you must use the development version of "),K=i(Ve,"A",{href:!0,rel:!0});var Zo=s(K);zt=r(Zo,"httpuv"),Zo.forEach(t),Qt=r(Ve," which resolves an issue with app timeouts on Hugging Face."),Ve.forEach(t),Xo.forEach(t),Qe.forEach(t),this.h()},h(){f(w,"name","hf:doc:metadata"),f(w,"content",JSON.stringify(na)),f(S,"id","shiny-on-spaces"),f(S,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(S,"href","#shiny-on-spaces"),f(g,"class","relative group"),f(A,"href","https://shiny.posit.co/"),f(A,"rel","nofollow"),f(k,"id","shiny-for-python"),f(k,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(k,"href","#shiny-for-python"),f(_,"class","relative group"),f(H,"href","https://shiny.rstudio.com/py/"),f(H,"rel","nofollow"),ea(ne.src,ro="https://huggingface.co/datasets/huggingface/badges/resolve/main/deploy-to-spaces-lg.svg")||f(ne,"src",ro),f(F,"href","https://huggingface.co/new-space?template=posit/shiny-for-python-template"),f(N,"href","https://shiny.rstudio.com/py/docs/overview.html"),f(N,"rel","nofollow"),f(I,"href","https://shiny.rstudio.com/py/docs/workflow-modules.html"),f(I,"rel","nofollow"),f(P,"id","shiny-for-r"),f(P,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(P,"href","#shiny-for-r"),f(b,"class","relative group"),f(q,"href","https://shiny.rstudio.com/"),f(q,"rel","nofollow"),f(C,"href","https://github.com/nanxstats/awesome-shiny-extensions"),f(C,"rel","nofollow"),f(G,"href","https://httr2.r-lib.org/"),f(G,"rel","nofollow"),f(L,"href","https://rstudio.github.io/reticulate/"),f(L,"rel","nofollow"),ea(ye.src,no="https://huggingface.co/datasets/huggingface/badges/resolve/main/deploy-to-spaces-lg.svg")||f(ye,"src",no),f(O,"href","https://huggingface.co/new-space?template=posit/shiny-for-r-template"),f(U,"href","https://hub.docker.com/r/rocker/shiny"),f(U,"rel","nofollow"),f(Y,"href","https://hub.docker.com/r/rocker/shiny-verse"),f(Y,"rel","nofollow"),f(K,"href","https://github.com/rstudio/httpuv"),f(K,"rel","nofollow")},m(e,n){o(document.head,w),h(e,ke,n),h(e,g,n),o(g,S),o(S,ie),to(R,ie,null),o(g,Xe),o(g,se),o(se,Ze),h(e,Pe,n),h(e,x,n),o(x,A),o(A,et),o(x,tt),h(e,Te,n),h(e,B,n),o(B,ot),h(e,Re,n),h(e,_,n),o(_,k),o(k,le),to($,le,null),o(_,at),o(_,re),o(re,it),h(e,xe,n),h(e,D,n),o(D,H),o(H,st),o(D,lt),h(e,Ae,n),h(e,J,n),o(J,rt),h(e,$e,n),h(e,F,n),o(F,ne),h(e,De,n),h(e,z,n),o(z,he),o(he,nt),h(e,He,n),h(e,d,n),o(d,ht),o(d,N),o(N,ft),o(d,pt),o(d,I),o(I,ut),o(d,ct),h(e,Fe,n),h(e,Q,n),o(Q,fe),o(fe,yt),h(e,Ne,n),h(e,V,n),o(V,mt),h(e,Ie,n),h(e,X,n),o(X,pe),o(pe,dt),h(e,Me,n),h(e,Z,n),o(Z,vt),h(e,qe,n),h(e,b,n),o(b,P),o(P,ue),to(M,ue,null),o(b,wt),o(b,ce),o(ce,gt),h(e,Ce,n),h(e,y,n),o(y,q),o(q,_t),o(y,bt),o(y,C),o(C,Et),o(y,St),o(y,G),o(G,kt),o(y,Pt),o(y,L),o(L,Tt),o(y,Rt),h(e,Ge,n),h(e,ee,n),o(ee,xt),h(e,Le,n),h(e,O,n),o(O,ye),h(e,Oe,n),h(e,m,n),o(m,me),o(me,At),o(m,$t),o(m,de),o(de,Dt),o(m,Ht),o(m,ve),o(ve,Ft),o(m,Nt),h(e,Ue,n),h(e,te,n),o(te,we),o(we,It),h(e,Ye,n),h(e,c,n),o(c,Mt),o(c,U),o(U,qt),o(c,Ct),o(c,Y),o(Y,Gt),o(c,Lt),o(c,ge),o(ge,Ot),o(c,Ut),o(c,_e),o(_e,Yt),o(c,jt),h(e,je,n),h(e,oe,n),o(oe,Kt),h(e,Ke,n),h(e,T,n),o(T,be),o(be,Ee),o(Ee,Wt),o(T,Bt),o(T,Se),o(Se,j),o(j,Jt),o(j,K),o(K,zt),o(j,Qt),We=!0},p:sa,i(e){We||(oo(R.$$.fragment,e),oo($.$$.fragment,e),oo(M.$$.fragment,e),We=!0)},o(e){ao(R.$$.fragment,e),ao($.$$.fragment,e),ao(M.$$.fragment,e),We=!1},d(e){t(w),e&&t(ke),e&&t(g),io(R),e&&t(Pe),e&&t(x),e&&t(Te),e&&t(B),e&&t(Re),e&&t(_),io($),e&&t(xe),e&&t(D),e&&t(Ae),e&&t(J),e&&t($e),e&&t(F),e&&t(De),e&&t(z),e&&t(He),e&&t(d),e&&t(Fe),e&&t(Q),e&&t(Ne),e&&t(V),e&&t(Ie),e&&t(X),e&&t(Me),e&&t(Z),e&&t(qe),e&&t(b),io(M),e&&t(Ce),e&&t(y),e&&t(Ge),e&&t(ee),e&&t(Le),e&&t(O),e&&t(Oe),e&&t(m),e&&t(Ue),e&&t(te),e&&t(Ye),e&&t(c),e&&t(je),e&&t(oe),e&&t(Ke),e&&t(T)}}}const na={local:"shiny-on-spaces",sections:[{local:"shiny-for-python",title:"Shiny for Python"},{local:"shiny-for-r",title:"Shiny for R"}],title:"Shiny on Spaces"};function ha(lo){return la(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ua extends ta{constructor(w){super();oa(this,w,ha,ra,aa,{})}}export{ua as default,na as metadata};
