M
M
Maxim Rezvanov2017-08-27 13:39:41
Flask
Maxim Rezvanov, 2017-08-27 13:39:41

How does flask and vue-router interact?

Hello. I'm trying to build a regular todo as a full spa on flask and vuejs. I ran into a routing problem. How to send paths in vue-router via flask?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
D3lphi, 2017-08-27
@brutedev

Regardless of whether you use flask or any other framework or write without it, a spa application is usually divided into 2 independent parts: frontend and backend. The first is the html css and js (vue, vue-router) and the second is the server logic itself. Data should be received using asynchronous (ajax) requests to the backend. That is, the backend, in this case, acts as an independent api.
For example, you want to write hello world by getting data from the server.

  • Create a route with path /example in vue-router.
  • In flask, you create the same route and handler for it, which will return data in json format.
  • Send an ajax request via js (For example, using the axios http client, it is the most popular), receive data, output.

A
Alexander, 2017-08-27
@boratsagdiev

I don't really understand what problem you are facing. But you probably still need to use vue-router's routes rather than flask's routes to navigate the SPA. And leave flask's routes alone as api endpoints.
Perhaps this page will be useful - https://router.vuejs.org/en/essentials/history-mod...

O
Oleg Agapov, 2017-10-23
@oleg_agapov

I also asked this question :) As a result, I figured it out and wrote an article:
https://codeburst.io/full-stack-single-page-applic...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question