Code Monkey home page Code Monkey logo

Comments (3)

jeromegn avatar jeromegn commented on May 13, 2024

Hey there!

Does this reference example code we got wrong? I saw there are talks about that in Slack.

The first code sample you show will only serve index.html because, as you've figured out, it's hard-coded in there.

We provide basic functionality for people to arrange in whatever way they need to make things work for their use cases.

In your second example, that seems like what you're trying to do: for every request, check if the path is available as file. The response from this fetch could be a 404 if the file is not found.

If you're trying to load an image, then you're not setting the right content-type header though.

We strongly encourage people to write their own routing logic or use a package that can do that for them. Since there's only one "fetch" handler (that fly.http.respondWith callback), you need to have some form of dispatcher for the logic.

I think we should make that clearer, for sure.

As for your solution description:

All file url paths that are in .fly.yml should be overwritten and only return that file unless otherwise specified.

I'm not sure I understand it. Maybe we need an example app that serves files from pathnames as best it can.

This also makes me wonder if we should try to infer the content-type to avoid confusion and easy-to-make mistakes.

What's the problem you want to solve? I believe the functionality works as intended. We could use a better example for it though :)

from fly.

mrkurt avatar mrkurt commented on May 13, 2024

I'm not sure I understand it. Maybe we need an example app that serves files from pathnames as best it can.

This also makes me wonder if we should try to infer the content-type to avoid confusion and easy-to-make mistakes.

I think we could make a basic static site app that does both of these pretty quickly. It'll be especially useful when we have globbing.

from fly.

zoecarver avatar zoecarver commented on May 13, 2024

@jeromegn

I'm not sure I understand it. Maybe we need an example app that serves files from pathnames as best it can.

After thinking about it, this was not a great idea and I think it would probably create more issues than it would solve. Documentation is probably the best rout in order to help people understand how it is supposed to be used.

Another solution might be doing something similar to what express does and have something like this:

app.use(express.static('public'))

For inferring the content-type, I completely agree - this would be a great feature.

I am happy to write some documentation on how to serve files, I am just not sure where the best place to do that would be. Maybe in a wiki?

from fly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.