Share app url without sharing the files and version

Hi Community!

I just want to share the URL of my application without sharing the Files and versions on Huggingface spaces. Is there any way to achieve this?

Hi @Kunal7 !

Is this for gradio or streamlit? To be clear, you’d like to share your space without people being able to read it’s source code?

I’ve a streamlit app that I’d like to host on huggingface spaces without people being able to read the source code. Is it possible to do so?

Hi @freddyaboulton!

Thanks for the response. I am trying to deploy my app on streamlit.

To be clear, you’d like to share your space without people being able to read its source code?

Yes, exactly. This is what I intend to do

Thanks for the clarification @Kunal7 and @tracinginsights ! There isn’t a built in solution for this at the moment. Will bring this up with the team!

@Kunal7 and @tracinginsights one thing you could do is clone a private repo from your app.py file and import your demo from there. I’ve seen that with gradio demos it might work with streamlit!

Can you please explain your use case a bit more? How come you’d like to keep the code private?

1 Like

That is actually a great idea, one can use that with fine-granular personal access token(PAT).

Create a PAT from GitHub with Content read access and use it as a password.

Basically, the link will become
https://YOUR_USERNAME:YOUR_PAT_TOKEN@github.com/YOUR_USERNAME/YOUR_REPOSITORY_NAME.git

It is not possible to use ssh (port 22) because only ports 80 and 443 are allowed.

Then, by using the gitpython library, the repository can be downloaded from the inside of the python script

Another way would be using SSH over HTTPS, I tried and learned a lot about underlying containers, I would be happy if anyone would like to try that. :slight_smile:

1 Like

I’ve created a PAT from Github with content read access and followed the other instructions. However I couldn’t figure out how to use gitpython, could you elaborate on this? I’ve tried git.Repo.clone_from() function and also tried using pygit2 package.

After installing gitpython, you can import it:

from git import Repo

And using clone_from()

Repo.clone_from("https://YOUR_USERNAME:YOUR_PAT_TOKEN@github.com/YOUR_USERNAME/YOUR_REPOSITORY_NAME.git", 
    "/repo_directory")

I assume you know putting your PAT Token to secrets and calling it from environment variables. Otherwise someone can read your private repository. The following document structure is expected:

your_huggingface_repo/
  app.py
  README.py
  repo_directory/
    inside_code.py

After downloading the repo:

import repo_directory.inside_code as inside_code

should be the last step.

1 Like

I’ve followed these steps and it works with default values, but whenever I make a different selection from drop-down it’s throwing an error

GitCommandError: Cmd('git') failed due to: exit code(128) cmdline: git clone -v https://*****:*****@github.com/TracingInsights/Charts.git repo_directory stderr: 'fatal: destination path 'repo_directory' already exists and is not an empty directory. '

My huggingface space is at: F1 Analysis - a Hugging Face Space by tracinginsights
My streamlit app is at: https://tracinginsights.streamlit.app/