Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use PlumberStatic #156

Closed
chenjr0719 opened this issue Aug 7, 2017 · 4 comments
Closed

Can't use PlumberStatic #156

chenjr0719 opened this issue Aug 7, 2017 · 4 comments

Comments

@chenjr0719
Copy link

As the documents says, plumber can use PlumberStatic to add and mount new static file router now.

But I can't use PlumberStatic, would you please do me a favor to solve this problem?

BTW, my plumber version is 0.4.2.

@trestletech
Copy link
Contributor

Hi. Can I get more details on what's going wrong?

The docs you referenced are specifically for building an API programatically. If you're using the more conventional format of commenting on your functions, you might be looking for https://www.rplumber.io/docs/routing-and-input.html#static-file-handler instead

e.g. adding something like

#* @assets ./files/static /static
list()

should make the ./files/static folder accessible at the /static URL on your API.

@chenjr0719
Copy link
Author

The directory structure is:
image

I try to run the code in doc and get the error like this:

image

That's because PlumberStatic doesn't available in this package
image

Before I reply this issue, I clone this repository and go to check the NAMESPACE, it seems that the function PlumberStatic not to be exported.

After add the comment #' @export at PlumberStatic and reinstall package, it appeared:
image

It should be worked, but actually not, I get 404 error when I visit http://127.0.0.1:8080/assets:
image

BTW, I also try your suggestion, but no luck:
image

Here is my plumber.R:

#* @assets ./myfiles /assets
list()

@trestletech
Copy link
Contributor

Doh! Sorry, the export should be solved in #163.

I think the problem you're seeing now is related to the fact that Plumber doesn't offer directory indexes (would be a nice feature). So you won't see anything at the root of the directory, but you should see something if you go to: localhost:8080/assets/test.txt

@chenjr0719
Copy link
Author

Oops, you are right. I can see something when I visit http://localhost:8080/assets/test.txt. That's my mistake and thanks for you to help me figure it out.

And the problem of PlumberStatic is also solved, this issue should be close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants