Coder Social home page Coder Social logo

serve static files from CDN about covid HOT 8 CLOSED

epidemics avatar epidemics commented on May 12, 2024
serve static files from CDN

from covid.

Comments (8)

gavento avatar gavento commented on May 12, 2024 1

Note: Main data files (JSON) are already served from GCS storage, which scales extremely well. We can upload assets too, I guess?

from covid.

hnykda avatar hnykda commented on May 12, 2024 1

@jez4 I just realized that I did something in the past (it's not in master anymore): https://github.com/epidemics/covid/pull/122/files

^ you IMO want to take this and move it to the deploy branch only (so it's iterated only on deploy) and in addition of setting that public access and cache control actually uploading everything gzipped.

from covid.

jez4 avatar jez4 commented on May 12, 2024 1

I have managed to upload static files to the bucket gzipped. Now the templates.

from covid.

jez4 avatar jez4 commented on May 12, 2024

@hnykda I am checking the deploy action in pythonapp.yml. I should add the gsutil cp there? I will need some more description :)

from covid.

hnykda avatar hnykda commented on May 12, 2024

Yes, it should be there on a deploy step. The command is IMO equivalent to the `push_to_bucket

The hard part seems to be actually rendering templates with different static URL paths for static files (I asked about it here encode/starlette#884).

In the first case, I propose to use something like:

APP_DEBUG = True  # local dev
STATIC_URL= "/static" if APP_DEBUG else "https://storage.googleapis.com/static-covid/static/"

...
def someview():
    return Template("<template>.html", {STATIC_URL: STATIC_URL})  # using e.g. `{{STATIC_URL}}/js/lines.js`

from covid.

jez4 avatar jez4 commented on May 12, 2024

I should use {{ STATIC_URL }} for templates

from covid.

jez4 avatar jez4 commented on May 12, 2024

The templates are done. Now just to perfect the workflow. I will ask for review afterwards.

from covid.

hnykda avatar hnykda commented on May 12, 2024

Closed via #333

from covid.

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.