{"id":2222,"date":"2022-01-25T17:41:16","date_gmt":"2022-01-25T17:41:16","guid":{"rendered":"https:\/\/lvboard.infostore.in.ua\/?p=2222"},"modified":"2022-01-25T17:41:16","modified_gmt":"2022-01-25T17:41:16","slug":"webapp-boilerplate-with-react-js-and-flask-api","status":"publish","type":"post","link":"https:\/\/lvboard.infostore.in.ua\/?p=2222","title":{"rendered":"WebApp boilerplate with React JS and Flask API"},"content":{"rendered":"\n<h3>Styles<\/h3>\n\n\n\n<p>You can update the&nbsp;<code>styles\/index.scss<\/code>&nbsp;or create new&nbsp;<code>.scss<\/code>&nbsp;files inside&nbsp;<code>styles\/<\/code>&nbsp;and import them into your current scss or js files depending on your needs.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h3>Components<\/h3>\n\n\n\n<p>Add more files into your&nbsp;<code>.\/src\/js\/components<\/code>&nbsp;or styles folder as you need them and import them into your current files as needed.<\/p>\n\n\n\n<p>?Note: There is an example using the Context API inside&nbsp;<code>views\/demo.js<\/code>;<\/p>\n\n\n\n<h3>Views (Components)<\/h3>\n\n\n\n<p>Add more files into your&nbsp;<code>.\/src\/js\/views<\/code>&nbsp;and import them in&nbsp;<code>.\/src\/js\/layout.jsx<\/code>.<\/p>\n\n\n\n<h3>Context<\/h3>\n\n\n\n<p>This boilerplate comes with a centralized general Context API. The file&nbsp;<code>.\/src\/js\/store\/flux.js<\/code>&nbsp;has a base structure for the store, we encourage you to change it and adapt it to your needs.<\/p>\n\n\n\n<p>React Context&nbsp;<a href=\"https:\/\/reactjs.org\/docs\/context.html\">docs<\/a><br>BreathCode Lesson&nbsp;<a href=\"https:\/\/content.breatheco.de\/lesson\/react-hooks-explained\">view<\/a><\/p>\n\n\n\n<p>The&nbsp;<code>Provider<\/code>&nbsp;is already set. You can consume from any component using the useContext hook to get the&nbsp;<code>store<\/code>&nbsp;and&nbsp;<code>actions<\/code>&nbsp;from the Context. Check&nbsp;<code>\/views\/demo.js<\/code>&nbsp;to see a demo.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { Context } from \"..\/store\/appContext\";\nconst MyComponentSuper = () =&gt; {\n  \/\/here you use useContext to get store and actions\n  const { store, actions } = useContext(Context);\n  return &lt;div&gt;{\/* you can use your actions or store inside the html *\/}&lt;\/div&gt;\n}<\/pre>\n\n\n\n<h3>Back-End Manual Installation:<\/h3>\n\n\n\n<p>It is recomended to install the backend first, make sure you have Python 3.8, Pipenv and a database engine (Posgress recomended)<\/p>\n\n\n\n<ol><li>Install the python packages:&nbsp;<code>$ pipenv install<\/code><\/li><li>Create a .env file based on the .env.example:&nbsp;<code>$ cp .env.example .env<\/code><\/li><li>Install your database engine and create your database, depending on your database you have to create a DATABASE_URL variable with one of the possible values, make sure yo replace the valudes with your database information:<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Engine<\/th><th>DATABASE_URL<\/th><\/tr><\/thead><tbody><tr><td>SQLite<\/td><td>sqlite:\/\/\/\/test.db<\/td><\/tr><tr><td>MySQL<\/td><td>mysql:\/\/username:password@localhost:port\/example<\/td><\/tr><tr><td>Postgress<\/td><td>postgres:\/\/username:password@localhost:5432\/example<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ol start=\"4\"><li>Migrate the migrations:&nbsp;<code>$ pipenv run migrate<\/code>&nbsp;(skip if you have not made changes to the models on the&nbsp;<code>.\/src\/api\/models.py<\/code>)<\/li><li>Run the migrations:&nbsp;<code>$ pipenv run upgrade<\/code><\/li><li>Run the application:&nbsp;<code>$ pipenv run start<\/code><\/li><\/ol>\n\n\n\n<h3>Front-End Manual Installation:<\/h3>\n\n\n\n<ul><li>Make sure you are using node version 14+ and that you have already successfully installed and runned the backend.<\/li><\/ul>\n\n\n\n<ol><li>Install the packages:&nbsp;<code>$ npm install<\/code><\/li><li>Start coding! start the webpack dev server&nbsp;<code>$ npm run start<\/code><\/li><\/ol>\n\n\n\n<h2>Publish your website!<\/h2>\n\n\n\n<p>This boilerplate it\u2019s 100% integrated with Herkou, just by pushing your changes to the heroku repository it will deploy:&nbsp;<code>$ git push heroku main<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/ \"prettier-webpack-plugin\": \"^1.2.0\",\n<\/code><\/pre>\n\n\n\n<p>\u201cdotenv-webpack\u201d: \u201c^1.7.0\u201d,<br>\u201cfriendly-errors-webpack-plugin\u201d: \u201c^1.7.0\u201d,<\/p>\n\n\n\n<h2>GitHub<\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/DanBaDo\/RAJ?ref=reactjsexample.com\" rel=\"noreferrer noopener\" target=\"_blank\">View Github<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Styles You can update the&nbsp;styles\/index.scss&nbsp;or create new&nbsp;.scss&nbsp;files inside&nbsp;styles\/&nbsp;and import them into your current scss or js files depending on your needs.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[30],"tags":[173,65],"_links":{"self":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts\/2222"}],"collection":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2222"}],"version-history":[{"count":1,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts\/2222\/revisions"}],"predecessor-version":[{"id":2223,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=\/wp\/v2\/posts\/2222\/revisions\/2223"}],"wp:attachment":[{"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lvboard.infostore.in.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}