Skip to content

Commit 8e103f7

Browse files
Merge pull request #22 from milancurcic/update-readme
Clean up and expand the README
2 parents 62558d6 + 81c4ab8 commit 8e103f7

File tree

6 files changed

+134
-25
lines changed

6 files changed

+134
-25
lines changed

README.md

Lines changed: 134 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,135 @@
1-
# playground
2-
An interactive Fortran playground
3-
4-
# Instructions to run
5-
6-
# Flask API
7-
1. Install Docker
8-
2. Build docker image (Switch to docker directory)
9-
``` docker build -t playground-f .```
10-
3. Install pipenv to manage packages
11-
```pip install pipenv```
12-
4. Switch to backend directory and
13-
```pipenv install```
14-
5. Run the flask server
15-
```pipenv run flask run```
16-
17-
Example request:
18-
`curl --location --request POST '127.0.0.1:5000/run' \ --header 'Content-Type: application/json' \ --data-raw '{ "code": "program hello\nprint *, \"Hello World New Line\"\nprint *, \"Hello Mars\"\nend program hello" } '`
19-
20-
# React frontend
21-
Switch to frontend folder
22-
1. Install node packages
23-
```npm install``
24-
2. Run the server
25-
```npm start```
1+
# The Fortran Playground
262

3+
This is an interactive Fortran playground in the browser.
4+
It's main purpose is for newcomers to easily get a taste for the language
5+
and learn the essentials of Fortran programming.
6+
7+
Follow the instructions below if you want to run the Fortran Playground server
8+
on your own computer.
9+
10+
## Getting started
11+
12+
### Get the code
13+
14+
```
15+
git clone https://github.com/fortran-lang/playground
16+
cd playground
17+
```
18+
19+
### Install dependencies
20+
21+
The key dependencies for the Fortran playground are:
22+
23+
* [Python](https://www.python.org/) for the backend server;
24+
* [Docker](https://www.docker.com/) for the container on the backend server;
25+
* [Node.js](https://nodejs.org/) for the frontend server.
26+
27+
Ensure these are installed on your system before proceeding.
28+
29+
### Set up the backend server
30+
31+
#### Build the Docker image
32+
33+
The Fortran playground relies on a Docker container in which the backend server
34+
runs the compiler and executes the code.
35+
For the playground to work, we need to be able to run `docker` as a non-root
36+
user, that is, without `sudo`.
37+
See the [additional configuration instructions](https://docs.docker.com/engine/install/linux-postinstall/)
38+
for how to do that on Linux.
39+
40+
When ready, type:
41+
42+
```
43+
cd backend/Docker
44+
docker build -t playground-f .
45+
```
46+
47+
To confirm that it worked, type `docker images` and you should see
48+
`playground-f` in the list of images under the `REPOSITORY` column, for example:
49+
50+
```
51+
REPOSITORY TAG IMAGE ID CREATED SIZE
52+
playground-f latest 8c2439e40e81 1 hour ago 201MB
53+
```
54+
55+
Now move one directory up where we will set up the Python environment and the
56+
required libraries:
57+
58+
```
59+
cd ..
60+
```
61+
62+
#### Install the Python libraries
63+
64+
The Python backend server and the packages that it depends on are managed using
65+
pipenv.
66+
If you don't have pipenv installed, you can install it using pip:
67+
68+
```
69+
pip install --user pipenv
70+
```
71+
72+
Or, if you don't have pip, use your OS's preferred package manager to install
73+
it.
74+
You can learn more about pipenv [here](https://pipenv.pypa.io/en/latest/).
75+
76+
When ready, type:
77+
78+
```
79+
pipenv install
80+
```
81+
82+
#### Run the backend server
83+
84+
To run the development server (Flask), type:
85+
86+
```
87+
pipenv run flask run
88+
```
89+
90+
While running, you can try to make an example HTTP request to the server from
91+
another terminal window using `curl`:
92+
93+
```
94+
curl \
95+
--location \
96+
--request POST '127.0.0.1:5000/run' \
97+
--header 'Content-Type: application/json' \
98+
--data-raw '{"code": "program hello\nprint *, \"Hello World New Line\"\nprint *, \"Hello Mars\"\nend program hello", "programInput": "", "libs": ""}'
99+
```
100+
101+
If everything is set up correctly so far, you should get the following response:
102+
103+
```
104+
{"executed":" Hello World New Line\n Hello Mars\n"}
105+
```
106+
107+
### Set up the frontend server
108+
109+
From the top-level directory of the Fortran playground, navigate to the
110+
frontend directory:
111+
112+
```
113+
cd frontend
114+
```
115+
116+
To install the Node.js dependencies, type:
117+
118+
```
119+
npm install
120+
```
121+
122+
Run the server by typing:
123+
124+
```
125+
npm start
126+
```
127+
128+
This should open the Fortran playground in your default web browser.
129+
If not, navigate to http://localhost:3000 in your browser to start the
130+
playground.
131+
132+
## Reporting issues
133+
134+
Please report any issues or suggestions for improvement by opening a
135+
[new GitHub issue](https://github.com/fortran-lang/playground/issues/new).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)