I have a flask application and using some intergration with backbone. But I cannot use backbone router because of the flask wsgi.But I want to have the backbone router history mechanism for this application. I know I can use google analytics but that is a separate thing. I want to have a record of all the urls browsed and want flask to record it.how can i do that ?
Simplest solution for recording every url from server side in Flask is a #before_request handler
#before_request
def log_url():
save(request.url)
Related
So I have the following idea: in order to make my SPA SEO friendly, I want to check on the server side if it's a web crawler (based on the headers), and if it is, I want to render the page with Puppeeteer and return it. Otherwise, I want it to be served as a normal SPA application.
I am using Firebase Hosting and want to do it with Firebase Cloud Functions. The thing is that I don't know how to normally serve the built React files from Functions. Can I somehow redirect it back to the Firebase Hosting?
Thanks!
To redirect from Cloud Functions to any other website (your firebase hosting), set a redirect header.
exports.cb = functions.https.onRequest((req, res) => {
res.redirect(`https://my-project.firebaseapp.com`);
});
I'm looking for a simple solution to deploy small React app with full React router support (no # urls). I've been using firebase so far, but I need to send an email from form, and used PHP for that.
Is there a service like firebase but with PHP support? Or can I somehow connect PHP file from other hosting (now I receive an error trying do so)?
You can use google cloud functions which allows to connect with the firebase.
For an example
-> ReactApp Form for UI
-> Firebase stores data based on users input through React App.
-> Google cloud function which gets called when there is an event in firebase database for an example (Create, update and delete). You can write logic in function which sends an email through send grid. You can write function in Nodejs and golang.
Example (https://cloud.google.com/functions/docs/tutorials/sendgrid)
I currently have a Single Page Application using( React+Redux+React-Router) hosted on firebase hosting. I want to implement server side rendering, for which I am aware I need to run a node/express server on something like Heroku, but I'm unclear how to do this. I have seen many starter boilerplates i.e Este that incorporate server-side-rendering but I want to add this capability to an existing Project. Somehow, The static content hosted on firebase should have access to my server but again unclear how to implement it so i can get al the benefits involved with SSR.
Since you are already using Firebase you can utilize Firebase functions.
Just setup a new function which intercepts your http request and then you just fetch all the stuff you need and render to a string with react routers render to string method.
There is a good tutorial covering all the bits and pieces of this here
https://m.youtube.com/watch?v=82tZAPMHfT4
I have an Ionic Framework app (v1) and a Node.js file that executes some functions to a credit-card API I'm using. I've been testing the execution of the node file with the following command on terminal:
$ node file.js
And it works perfectly with my local machine. The problem is that I'll use my app for production soon, so how can I run this server-side code after a button click event in my front-end app ? Do I need to store this node file in the server and access it with angular http service ? How can I trigger the execution remotely?
I'm currently using Firebase as my back-end.
I've been struggling with this for days and I'm pretty new to Node.js. Please help me.
In terms of architecture and best practices, I recommend you to create an NodeJS API application and your Ionic app will make request to this API. You need to define route(s) to your NodeJS app, put it in production to provide Ionic app to send requests to its route(s).
As you sad that is a simple function, look at Express that is a NodeJS framework. The routing guide shows how to create a simple route using this framework.
To summarize, your Ionic app will send requests to NodeJS API route and this route will execute some functions to your credit card API.
I am using a rails api with devise gem to login to facebook. When i use a link from an html under the rails app directly to login. It works perfectly.
Now if i try to move to a client with angular2 and call the same route in the rails app. The problem occur in the redirect to facebook. I can hit the route cause i have already setuped "cors rack gem" but when behind the scene "devise gem" call the facebook api the origin for this call is null. I didn't find a way to get it work after 3h searching.
anyone setuped angular (1 or 2) with rails api and devise/omniauth?
the rails api and the angular app are under different domain
I endup using this gem for token based auth.
https://github.com/lynndylanhurley/devise_token_auth
I have removed devise totally from my gem file and i am using only "devise_token_auth" now.
You need to use a frontend library as for angular1
https://github.com/lynndylanhurley/ng-token-auth to call the api.
In my case i just used the demo from ng-token-auth, i extract the parameters from the call to register and used this parameters in a normal ajax call in my angular2 app => i was able to create a user.
normally devise_token_auth handle facebook proprely for ajax call (didn't try it yet)