|
1 |
| -# Project Name |
| 1 | +# flask-reactize |
2 | 2 |
|
3 |
| -(short, 1-3 sentenced, description of the project) |
| 3 | +[](https://badge.fury.io/py/flask-reactize) |
| 4 | + |
| 5 | +Developing a ReactJS application requires to use nodejs as back end server. |
| 6 | +What if you want to consume external APIs: how are you going to handle cross origin calls? |
| 7 | + |
| 8 | +In modern days, as we are now, [React JS](https://reactjs.org/) offers many nice functionalities to develop an application easily, from any IDE. |
| 9 | + |
| 10 | +In development mode, [React JS](https://reactjs.org/) requires [NodeJS](https://nodejs.org/en/) as a back end server. [NodeJS](https://nodejs.org/en/) maintains a connection between your development environment and your browser where the application is loaded so that: |
| 11 | + |
| 12 | +* it refreshes automatically when an update is made, |
| 13 | +* it sends in real time any error, warning that may have, in both the console and the developers toolbar of your browser of choice. |
| 14 | + |
| 15 | +For production, you can compile your [React JS](https://reactjs.org/) application into static assets - you can then use any technology to serve those static files. |
| 16 | + |
| 17 | +However, if your [React JS](https://reactjs.org/) calls external APIs (whether there are customs, or public) you will face security issues. |
4 | 18 |
|
5 | 19 | ## Features
|
6 | 20 |
|
7 |
| -This project framework provides the following features: |
| 21 | +*flask-reactize* is a boostrap to serve any [React JS](https://reactjs.org/) via a Python back-end, using [Flask](https://flask.palletsprojects.com/en/2.0.x/) as web framework. |
| 22 | + |
| 23 | +Your back-end web server can be anything: [Flask](https://flask.palletsprojects.com/en/2.0.x/) itself (although not recommended for production), [Uvicorn](https://www.uvicorn.org/), [Gunicorn](https://gunicorn.org/) etc. |
| 24 | + |
| 25 | +In a nutshell, *flask-reactize* is a proxy for your [React JS](https://reactjs.org/) application and for your APIs: |
8 | 26 |
|
9 |
| -* Feature 1 |
10 |
| -* Feature 2 |
11 |
| -* ... |
| 27 | +* It has a development mode: a nodejs server is transparently started by the Python back-end, |
| 28 | +* It supports production mode: this back-end can also serve your static assets, |
| 29 | +* It supports hot reload while developing: changing the Python code or the React code will trigger a browser refresh, |
| 30 | +* It supports proxying multiple APIs via specific routes. |
12 | 31 |
|
13 | 32 | ## Getting Started
|
14 | 33 |
|
| 34 | +Here is what you are going to find in this repo: |
| 35 | + |
| 36 | +* Under *src/flask-reactize* you will find the Python module (also available via [PyPi](https://pypi.org/project/flask-reactize/)), |
| 37 | +* Under *sample/* you will find a simple demo site built with [React JS](https://reactjs.org/) using *flask-reactize*, |
| 38 | +* Two *DockerFile* for Python 3.8 and Python 3.10. |
| 39 | + |
15 | 40 | ### Prerequisites
|
16 | 41 |
|
17 |
| -(ideally very short, if any) |
| 42 | +* [vscode](https://code.visualstudio.com/) because you are going to use [DevContainers](https://code.visualstudio.com/docs/remote/containers) to have all prerequisites without any hassle, |
| 43 | +* [Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) extension, |
| 44 | +* [docker](https://www.docker.com/) |
| 45 | + |
| 46 | +### Quickstart with Docker |
| 47 | + |
| 48 | +To experiment in a minimum of effort what this library is doing, follow the steps below: |
| 49 | + |
| 50 | +1. git clone https://github.com/Azure-samples/flask-reactize |
| 51 | +2. cd flask-reactize |
| 52 | +3. code . |
| 53 | + |
| 54 | +Once [vscode](https://code.visualstudio.com/) is opened, build the development container: |
| 55 | + |
| 56 | +1. open the Palette (Ctrl+Shift+P / Cmd+Shift+P) |
| 57 | +2. select *Remote-Containers: Reopen in container* |
| 58 | + |
| 59 | +Once the container is built, your [vscode](https://code.visualstudio.com/) is fully operational. If you open the terminal built in [vscode](https://code.visualstudio.com/), you will be prompted directly inside the container, as a "dummy" user called *alex*. |
18 | 60 |
|
19 |
| -- OS |
20 |
| -- Library version |
21 |
| -- ... |
| 61 | +You can now build the *flask-reactize* container to test *flask-reactize* in either Python 3.8 or 3.10 version |
22 | 62 |
|
23 |
| -### Installation |
| 63 | +1. run `make docker-build-sample-py38` in the terminal for Python 3.8 |
| 64 | +2. OR run `make docker-build-sample-py310` in the terminal for Python 3.10 |
| 65 | +3. then run `make docker-run-sample` to start the sample demo site |
24 | 66 |
|
25 |
| -(ideally very short) |
| 67 | +> If running the commands above result in an access is denied for the file `/var/run/docker.sock`, ensure that your user is the owner of this file. If it is not the case, run `sudo chown alex:alex /var/run/docker.sock` in the terminal. |
26 | 68 |
|
27 |
| -- npm install [package name] |
28 |
| -- mvn install |
29 |
| -- ... |
| 69 | +You can now open your browser and load the url [http://localhost:8080](http://localhost:8080). |
30 | 70 |
|
31 |
| -### Quickstart |
32 |
| -(Add steps to get up and running quickly) |
| 71 | +This sample uses [req|res](https://reqres.in) test APIs. |
33 | 72 |
|
34 |
| -1. git clone [repository clone url] |
35 |
| -2. cd [respository name] |
36 |
| -3. ... |
| 73 | +### Use this library in your project |
37 | 74 |
|
| 75 | +**Please note** that you need to be on a *nix system for that, whether you are on Linux, Mac or Windows with [WSL](https://docs.microsoft.com/en-us/windows/wsl/about). |
38 | 76 |
|
39 |
| -## Demo |
| 77 | +Instructions to follow can be found [here](./src/flask-reactize/README.md). |
40 | 78 |
|
41 |
| -A demo app is included to show how to use the project. |
| 79 | +### Deploy to Azure |
42 | 80 |
|
43 |
| -To run the demo, follow these steps: |
| 81 | +You can deploy your web application on Azure following one of the following methods (non exhaustive list): |
44 | 82 |
|
45 |
| -(Add steps to start up the demo) |
| 83 | +1. Using [Web App for Containers](https://docs.microsoft.com/en-us/azure/app-service/quickstart-custom-container?tabs=dotnet&pivots=container-linux), |
| 84 | +2. Using a [Web App](https://docs.microsoft.com/en-US/azure/app-service/quickstart-python?tabs=flask%2Cwindows%2Cazure-portal%2Cterminal-bash%2Cvscode-deploy%2Cdeploy-instructions-azportal%2Cdeploy-instructions-zip-azcli), |
| 85 | +3. Using [Azure Kubernetes Service](https://azure.microsoft.com/en-us/services/kubernetes-service/#overview) in a multi-scalable containers scenario. |
46 | 86 |
|
47 |
| -1. |
48 |
| -2. |
49 |
| -3. |
| 87 | +## Changelog |
50 | 88 |
|
51 |
| -## Resources |
| 89 | +Changelog can be found [here](./CHANGELOG.md). |
52 | 90 |
|
53 |
| -(Any additional resources or related projects) |
| 91 | +## Contributing |
54 | 92 |
|
55 |
| -- Link to supporting information |
56 |
| -- Link to similar sample |
57 |
| -- ... |
| 93 | +If you want to contribute to *flask-reactize*, [follow this guide](./CONTRIBUTING.md). |
0 commit comments