|
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 | +What if you want to secure your application and APIs easily? |
| 8 | + |
| 9 | +In modern days, as we are now, [React JS](https://reactjs.org/) offers many nice functionalities to develop an application easily, from any IDE. |
| 10 | + |
| 11 | +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: |
| 12 | + |
| 13 | +* it refreshes automatically when an update is made, |
| 14 | +* it sends in real time any error, warning that may have, in both the console and the developers toolbar of your browser of choice. |
| 15 | + |
| 16 | +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. |
| 17 | + |
| 18 | +However, if your [React JS](https://reactjs.org/) calls external APIs (whether there are customs, or public) you will face security issues. |
| 19 | + |
| 20 | +In addition, if your APIs require to be logged in, this is not going to be easy to implement. |
4 | 21 |
|
5 | 22 | ## Features
|
6 | 23 |
|
7 |
| -This project framework provides the following features: |
| 24 | +*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. |
8 | 25 |
|
9 |
| -* Feature 1 |
10 |
| -* Feature 2 |
11 |
| -* ... |
| 26 | +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. |
| 27 | + |
| 28 | +In a nutshell, *flask-reactize* is a proxy for your [React JS](https://reactjs.org/) application and for your APIs. |
| 29 | + |
| 30 | +* It has a development mode: a nodejs server is transparently started by the Python back-end, |
| 31 | +* It supports production mode: this back-end can also serve your static assets, |
| 32 | +* It supports hot reload while developing: changing the Python code or the React code will trigger a browser refresh, |
| 33 | +* It supports proxying multiple APIs via a specific route name. |
12 | 34 |
|
13 | 35 | ## Getting Started
|
14 | 36 |
|
| 37 | +Here is what you are going to find in this repo: |
| 38 | + |
| 39 | +* Under *src/flask-reactize* you will find the Python module (also available via [PyPi](https://pypi.org/project/flask-reactize/)). [More info](./src/flask-reactize/README.md), |
| 40 | +* Under *sample/* you will find a simple demo site built with [React JS](https://reactjs.org/) using *flask-reactize*. [More info on how to use it](./sample/README.md), |
| 41 | +* Two *DockerFile* for Python 3.8 and Python 3.10. To run them. |
| 42 | + |
15 | 43 | ### Prerequisites
|
16 | 44 |
|
17 |
| -(ideally very short, if any) |
| 45 | +* [vscode](https://code.visualstudio.com/) installed because you are going to use [DevContainers](https://code.visualstudio.com/docs/remote/containers) to have all prerequisites without any hassle, |
| 46 | +* [Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) extension, |
| 47 | +* [docker](https://www.docker.com/) |
| 48 | + |
| 49 | +### Quickstart with Docker |
| 50 | + |
| 51 | +To experiment in a minimum of effort what this library is doing, follow the steps below: |
| 52 | + |
| 53 | +1. git clone https://github.com/Azure-samples/flask-reactize |
| 54 | +2. cd flask-reactize |
| 55 | +3. code . |
18 | 56 |
|
19 |
| -- OS |
20 |
| -- Library version |
21 |
| -- ... |
| 57 | +Once [vscode](https://code.visualstudio.com/) is opened, build the development container: |
22 | 58 |
|
23 |
| -### Installation |
| 59 | +1. open the Palette (Ctrl+Shift+P / Cmd+Shift+P) |
| 60 | +2. select *Remote-Containers: Reopen in container* |
24 | 61 |
|
25 |
| -(ideally very short) |
| 62 | +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*. |
26 | 63 |
|
27 |
| -- npm install [package name] |
28 |
| -- mvn install |
29 |
| -- ... |
| 64 | +You can now build the *flask-reactize* container to test *flask-reactize* in either Python 3.8 or 3.10 version |
30 | 65 |
|
31 |
| -### Quickstart |
32 |
| -(Add steps to get up and running quickly) |
| 66 | +1. run `make docker-build-sample-py38` in the terminal for Python 3.8 |
| 67 | +2. OR run `make docker-build-sample-py310` in the terminal for Python 3.10 |
| 68 | +3. then run `make docker-run-sample` to start the sample demo site |
33 | 69 |
|
34 |
| -1. git clone [repository clone url] |
35 |
| -2. cd [respository name] |
36 |
| -3. ... |
| 70 | +> 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. |
37 | 71 |
|
| 72 | +You can now open your browser and load the url [http://localhost:8080](http://localhost:8080) |
38 | 73 |
|
39 |
| -## Demo |
| 74 | +## Use this library in your project |
40 | 75 |
|
41 |
| -A demo app is included to show how to use the project. |
| 76 | +**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). |
42 | 77 |
|
43 |
| -To run the demo, follow these steps: |
| 78 | +Instructions to follow can be found [here](./src/flask-reactize/README.md). |
44 | 79 |
|
45 |
| -(Add steps to start up the demo) |
| 80 | +## Deploy to Azure |
46 | 81 |
|
47 |
| -1. |
48 |
| -2. |
49 |
| -3. |
| 82 | +You can deploy your web application on Azure following one of the following methods (non exhaustive list): |
50 | 83 |
|
51 |
| -## Resources |
| 84 | +1. Using [Web App for Containers](https://docs.microsoft.com/en-us/azure/app-service/quickstart-custom-container?tabs=dotnet&pivots=container-linux), |
| 85 | +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), |
| 86 | +3. Using [Azure Kubernetes Service](https://azure.microsoft.com/en-us/services/kubernetes-service/#overview) in a multi-scalable containers scenario. |
52 | 87 |
|
53 |
| -(Any additional resources or related projects) |
| 88 | +## Contributing |
54 | 89 |
|
55 |
| -- Link to supporting information |
56 |
| -- Link to similar sample |
57 |
| -- ... |
| 90 | +If you want to contribute to *flask-reactize*, [follow this guide](./CONTRIBUTING.md). |
0 commit comments