{"id":16195497,"url":"https://github.com/thiefmaster/flask-cra-example","last_synced_at":"2025-03-19T04:30:54.863Z","repository":{"id":39477549,"uuid":"195381416","full_name":"ThiefMaster/flask-cra-example","owner":"ThiefMaster","description":"Example on how to integrate Flask and React (create-react-app)","archived":false,"fork":false,"pushed_at":"2023-01-04T03:43:56.000Z","size":3825,"stargazers_count":12,"open_issues_count":21,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T15:59:46.871Z","etag":null,"topics":["create-react-app","flask","react","reactjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThiefMaster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-05T09:29:03.000Z","updated_at":"2024-10-30T10:08:49.000Z","dependencies_parsed_at":"2023-02-01T19:01:08.599Z","dependency_job_id":null,"html_url":"https://github.com/ThiefMaster/flask-cra-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiefMaster%2Fflask-cra-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiefMaster%2Fflask-cra-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiefMaster%2Fflask-cra-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiefMaster%2Fflask-cra-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThiefMaster","download_url":"https://codeload.github.com/ThiefMaster/flask-cra-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243971156,"owners_count":20376784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["create-react-app","flask","react","reactjs"],"created_at":"2024-10-10T08:28:22.352Z","updated_at":"2025-03-19T04:30:54.530Z","avatar_url":"https://github.com/ThiefMaster.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask \u0026 create-react-app\n\nThis is an example on how to use a react frontend in your Flask app.\nIt uses [`create-react-app`][cra] (CRA) so you don't need to configure much yourself!\n\nNote that CRA is mainly for single-page apps - so if that's not what you want,\nthen you may want to configure webpack yourself instead.\n\n## Installation\n\n- Create and activate a virtualenv\n- `pip install -e .`\n- Inside the `flask_cra_example/client/` directory: `npm install`\n\n## Running\n\n### Dev server\n\n- Use `flask run` as usual to start the dev server.\n- Inside the `flask_cra_example/client/` directory, use `npm start` to run the CRA dev server.\n\nNote: The frontend will proxy all `/api/` requests to the Flask app, which it expects\non `http://127.0.0.1:5000`.\n\nYou can use the `FLASK_URL` env var to override this (it's used in `setupProxy.js` - see\nthe [CRA docs][cra-proxy] for details on the proxy feature).\n\nTo access your app, go to `http://localhost:3000` (you can use `PORT` env var if you want\na different port).\n\n### Production build (development)\n\nThe CRA server, just like the Flask dev server, is not meant for production. Luckily CRA\nprovides an option to do a static build for production: `npm run build`\n\nThe Flask app is configured to serve those files correctly when accessed directly, so\nafter building you can go to `http://localhost:5000` and your webapp should work.\n\nNote that in this case autoreloading is not available and you need to run `npm run build`\nwhenever you changed something in the frontend.\n\n### Production\n\nFor a real production deployment, you use `npm run build` as well, but instead of using\nthe Flask dev server you use a real web server (like nginx+uwsgi).\n\nAlso, there's no reason to have your frontend served through Flask - so the web server should\nbe configured to serve the files from the `flask_cra_example/client/build` directory,\nand only forward `/api/` requests to the Flask app.\n\n## Your own app\n\nIf you want to use this in your own app, **do not** just copy the whole `client` folder!\n\nInstead, use `npx create-react-app client` to create it from scratch. All you then need to do\nis updating a few things to integrate e.g. with the Flask routing system to build URLs.\n\nCheck the commits in this repo to see what changes were done - it's not much, and by running\n`create-react-app` yourself you are sure to have the latest version of it!\n\n[cra]: https://facebook.github.io/create-react-app/\n[cra-proxy]: https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiefmaster%2Fflask-cra-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiefmaster%2Fflask-cra-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiefmaster%2Fflask-cra-example/lists"}