guerard / ce-placemats-flask Goto Github PK
View Code? Open in Web Editor NEWFlask API that powers CE Placemats
Flask API that powers CE Placemats
Since the data building tasks run asynchronously, we cannot simply forward the client's auth0 token when calling CE server. Instead we'll need to authenticate the flask API either as a separate client in auth0 (there's a client-type for server-side apps), or authenticate using non-auth0 methods (e.g. signature in the request header similar to how AWS authenticates requests).
Flask API should validate the auth0 tokens provided to it from the client.
Currently when an existing layout is fetched, we simply return it (line 25 in layouts_api.py).
Instead, we need to check if a query param refresh
is set to 1 or true and re-run the layout-creation logic (including adding widgets to the widget store and enqueueing tasks to generate the data) with one critical difference: update
the layout in the store vs. add
it.
The way update works is that it takes the primary key (pk
) as the first argument and the change dictionary as the second: in this case the only field we're changing is widgets
so the call would look something like l_store.update(pk, {'widgets': w_pks})
. update
.
Both of the above API's will need to use _get_query_or_default
from base_api.py to get the refresh query parameter.
The task queue remembers job requests for an hour, so that it can de-dupe any simultaneous requests. This means that you can only refresh the data once per hour. We can always add a hard_refresh
in the future that will actually delete/overwrite the status of the existing task in the queue, but for now it's probably better to throttle widget data creation to once per hour anyway (at least in production; for development purposes this would be tedious, but you can always just delete the entire task queue collection in mongo to reset it).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.