gtalarico/flask-vuejs-template

Question: backend python files?

hubitor opened this issue · 4 comments

Where backend python files go and how should they look like? What should be done to return a simple message at a new route? Please give an example.

I'm sorry I don't understand your fist question.

Routes can be added on the backend on the resources.py file (see flaskrest plus documentation) and on the front end application on the router.js file (see vue router docs).

I'm sorry I don't understand your fist question.
From the README:

This combination allows you have both your backend python files and the Vue appplication files auto-reload on save.

Routes can be added on the backend on the resources.py file (see flaskrest plus documentation) and on the front end application on the router.js file (see vue router docs).

I've taken a look into the flaskrest plus but I still can't figure out how to create a new route with a simple message.

@hubitor
The endpoints for this project are created here - you can copy them and modify:
https://github.com/gtalarico/flask-vuejs-template/blob/master/app/api/rest/resources.py#L14

The pattern is something like this:

@api_rest.route('/message')
class ResourceMessage(BaseResource):

    def get(self):
        return {'message': 'Message'}

This will return {'message': 'Message'} at /api/message

This template uses flask rest plus to manage the backend endpoints + resources,
so if you need more details you should look at the documentation for that project:
http://flask-restplus.readthedocs.io/en/stable/

If you don't need rest-style resource routing, you can always use flask's app/blueprint routing.
https://github.com/gtalarico/flask-vuejs-template/blob/master/app/client/__init__.py#L13

@app.route('/endpoint')
def view():
    return 'message'

@gtalarico: Thanks, both ways seem to be working now.