{"id":18840191,"url":"https://github.com/fortran-lang/playground","last_synced_at":"2025-04-14T07:06:11.901Z","repository":{"id":38533952,"uuid":"496667621","full_name":"fortran-lang/playground","owner":"fortran-lang","description":"An interactive Fortran playground","archived":false,"fork":false,"pushed_at":"2024-01-13T11:42:53.000Z","size":2421,"stargazers_count":35,"open_issues_count":16,"forks_count":10,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-14T07:05:06.403Z","etag":null,"topics":["fortran","playground","webapp"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fortran-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-05-26T15:10:28.000Z","updated_at":"2025-03-28T04:54:37.000Z","dependencies_parsed_at":"2024-01-23T01:03:00.399Z","dependency_job_id":"b28a6822-9a02-4ae7-9bbb-84b99a3e7c21","html_url":"https://github.com/fortran-lang/playground","commit_stats":{"total_commits":58,"total_committers":7,"mean_commits":8.285714285714286,"dds":0.3448275862068966,"last_synced_commit":"3d4d85309324765e13a25ce1ebb815513463979d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortran-lang%2Fplayground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortran-lang%2Fplayground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortran-lang%2Fplayground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortran-lang%2Fplayground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fortran-lang","download_url":"https://codeload.github.com/fortran-lang/playground/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837281,"owners_count":21169374,"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":["fortran","playground","webapp"],"created_at":"2024-11-08T02:45:20.200Z","updated_at":"2025-04-14T07:06:11.862Z","avatar_url":"https://github.com/fortran-lang.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Fortran Playground\n\nThis is an interactive Fortran playground in the browser.\nIts main purpose is for newcomers to easily get a taste for the language\nand learn the essentials of Fortran programming.\n\nFollow the instructions below if you want to run the Fortran Playground server\non your own computer.\nFor the design of the software, see [this document](DESIGN.md).\n\n## Getting started\n\n### Get the code\n\n```\ngit clone https://github.com/fortran-lang/playground\ncd playground\n```\n\n### Install dependencies\n\nThe key dependencies for the Fortran playground are:\n\n* [Python](https://www.python.org/) for the backend server;\n* [Docker](https://www.docker.com/) for the container on the backend server;\n* [Node.js](https://nodejs.org/) for the frontend server.\n\nEnsure these are installed on your system before proceeding.\n\n### Set up the backend server\n\n#### Build the Docker image\n\nThe Fortran playground relies on a Docker container in which the backend server\nruns the compiler and executes the code.\nFor the playground to work, we need to be able to run `docker` as a non-root\nuser, that is, without `sudo`.\nSee the [additional configuration instructions](https://docs.docker.com/engine/install/linux-postinstall/)\nfor how to do that on Linux.\n\nWhen ready, type:\n\n```\ncd backend/Docker\ndocker build -t playground-prod .\n```\n\nTo confirm that it worked, type `docker images` and you should see\n`playground-prod` in the list of images under the `REPOSITORY` column, for example:\n\n```\nREPOSITORY     TAG       IMAGE ID       CREATED         SIZE\nplayground-prod   latest    8c2439e40e81   1 hour ago      201MB\n```\n\nNow move one directory up where we will set up the Python environment and the\nrequired libraries:\n\n```\ncd ..\n```\n\n#### Install the Python libraries\n\nThe Python backend server and the packages that it depends on are managed using\npipenv.\nIf you don't have pipenv installed, you can install it using pip:\n\n```\npip install --user pipenv\n```\n\nOr, if you don't have pip, use your OS's preferred package manager to install\nit.\nYou can learn more about pipenv [here](https://pipenv.pypa.io/en/latest/).\n\nWhen ready, type:\n\n```\npipenv install\n```\n\n#### Run the backend server\n\nTo run the development server (Flask), type:\n\n```\npipenv run flask run\n```\n\nWhile running, you can try to make an example HTTP request to the server from\nanother terminal window using `curl`:\n\n```\ncurl \\\n  --location \\\n  --request POST '127.0.0.1:5000/run' \\\n  --header 'Content-Type: application/json' \\\n  --data-raw '{\n    \"code\": \"program hello\\r\\n  print *, \\\"Hello, World!\\\"\\r\\nend program hello\\r\\n\",\n    \"programInput\": \"\",\n    \"libs\" : []\n}'\n```\n\nIf everything is set up correctly so far, you should get the following response:\n\n```\n{\"executed\":\" Hello, World!\\n\"}\n```\n\n### Set up the frontend server\n\nFrom the top-level directory of the Fortran playground, navigate to the\nfrontend directory:\n\n```\ncd frontend\n```\n\nTo install the Node.js dependencies, type:\n\n```\nnpm install\n```\n\nRun the server by typing:\n\n```\nREACT_APP_PLAYGROUND_API_URL=http://localhost:5000 npm start\n```\n\nThis should open the Fortran playground in your default web browser.\nIf not, navigate to http://localhost:3000 in your browser to start the\nplayground.\n\nThe `REACT_APP_PLAYGROUND_API_URL` must be set in the environment\n(or, alternatively, in the `.env` file in the `frontend/` directory)\nto the URL value of the Python backend server to use.\nFor example, if you're running the Python backend server locally in development\nmode, set `REACT_APP_PLAYGROUND_API_URL` to `http://localhost:5000`.\nIf deploying to production, `REACT_APP_PLAYGROUND_API_URL` should be set to\n`https://play-api.fortran-lang.org`.\n\n### Loading Fortran code from your website in the playground\n\nThe Playground can Load code from your website by adding a parameter `code` to the URL of Playground. Please **Note:** that the value of the parameter code has to be fortran code which has been **URL Encoded** . This can be done by using JS function `encodeURIComponent()` with the code as its parameter. \n\nExample: https://play.fortran-lang.org/?code=program+hello%0D%0A++%21+This+is+a+comment+line%3B+it+is+ignored+by+the+compiler%0D%0A++print+%2A%2C+%27Hello%2C+World%21%27%0D%0Aend+program+hello%0D%0A\n\nHere, the fortran program for Hello World has been URL encoded and set to parameter `code` in the URL.\n\n\n## Deploying to production\n\nThis is a guide for deploying the Python backend to production.\n\n### Set up the VM\n\nThis is a setup guide to host the server on AWS EC2.\nIt assumes you already have an account.\nThe steps may be somewhat different on other cloud providers.\n\n1. Start the EC2 Launch Instance Wizard.\n2. Select Ubuntu 22.04 LTS x86 as your OS under the AMI section.\n2. Select the `t2.micro` instance if you want to stay within the free tier and\nkeep the configuration as default.\n3. Select the amount storage you need; 20 GBs will suffice and will stay under\nthe free tier. Go to next step and leave tags as default.\n4. Configure the security group to allow:\n  * SSH on port 22;\n  * HTTP on port 80;\n  * HTTPS on port 443;\nAll ports should allow the source to be \"Anywhere\", i.e. 0.0.0.0/0.\n5. Select or create your SSH key pair, and keep your private key safe.\n\nNext, attach an Elastic IP to this instance so that the VM receives a static IP\naddress.\n\n1. Select Elastic IP in the navigation panel, and create a new Elastic IP.\n2. Associate this Elastic IP to the instance you've just created.\n3. Go to your instance and note this Elastic IP\n  (you'll see it listed under the v4 IP address).\n\n### Connect to and prepare the VM\n\n1. Locate your SSH private key file that you created or selected in step 5\nand connect to your server by using SSH:\n```\nssh -i \u003cpem-file\u003e ubuntu@\u003cpublic-ip-address\u003e\n```\n2.  Update your instance\n```\nsudo apt update\nsudo apt upgrade\n```\nIf prompted to reboot after the upgrade is complete, reboot the VM from the AWS\ncontrol panel and log back in to the VM using SSH as described in the previous\nstep.\n3. Download [Caddy](https://caddyserver.com).\nWe will use Caddy as a reverse-proxy server in front of the Python server\nas well as for the SSL certificate.\nThe downloaded file is a static binary program.\nMake it executable (`chmod +x caddy`) and place it in a directory that is\nmeant for external programs, for example `/opt/caddy-2.5.2/bin` or similar.\nThis guide, and the\n[reverse-proxy service file](systemd/playground-reverse-proxy.service)\nassume that Caddy is executable and present in `/opt/caddy-2.5.2/bin`.\n3. Follow the instructions from the [Getting started section](#getting-started)\nto get the playground code, install Docker and the Python backend dependencies.\nBefore running the `pipenv install` step for the Python backend, make a\ndirectory for the virtual environment using `mkdir .venv`.\nThis will allow us to run the production server directly from\n`playground/backend/.venv/bin`.\n\n### Create or update the DNS record\n\nThis guide assumes that the backend server of the Fortran Playground\nwill serve at the play-api.fortran-lang.org subdomain.\nRegardless of whether this is the first deployment to production or not,\nensure that there is an A record for play-api.fortran-lang.org that\npoints to the public IP address of the VM.\n\n### Start the backend server and reverse proxy\n\nsystemd service files for the Python backend server and reverse proxy\nare provided in the playground/systemd directory.\nTo start and enable the services, type:\n\n```\ncd systemd\nsudo ./initialize-services.sh\n```\n\nwhich will copy the service files to `/etc/systemd/system`,\nstart them, and enable them so they start on every boot.\n\n## Reporting issues\n\nPlease report any issues or suggestions for improvement by opening a\n[new GitHub issue](https://github.com/fortran-lang/playground/issues/new).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortran-lang%2Fplayground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffortran-lang%2Fplayground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortran-lang%2Fplayground/lists"}