Note: This app previously used PHP and was recently upgraded to NodeJS. The old PHP is in script.php.old and is no longer used. If you would like to use PHP, you can rename this file to script.php and modify the submit.js to fetch from script.php amd see Old Instructions for PHP.
- Clone or download this repo
- Set the environment varialbe for OPENAI_API_KEY to your OpenAI API Key
- Ensure that
const UseAWS = false;
is set at the top of the server.js file - Create a .env file in the repo folder with the following:
OPENAI_API_KEY="[REPLACE_WITH_YOUR_KEY]"
- Open a terminal window and navigate to the repo folder and run
npm install
(note you must have Node installed). This will install the proper node packages. - In the terminal with the repo folder navigated to, start the server with
node server.js
this will run the server on port 8000. - Open the Index.html file
- Create an EC2 server and install Apache (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateWebServer.html)
- Place the files from this repository in the /var/www/html folder
- Open up the necessary ports to your EC2 server (80 for HTTP and 443 for HTTPS)
- Create a secret in SSM Parameter store called OPENAI_API_KEY and set this to your OpenAI API Key
- Attach a role to your EC2 instance that allows access to this key
- Ensure that
const UseAWS = true;
is set at the top of the server.js file and that the proper details are put into the $ssmClient creation (you likely will need to just change the region if you created your EC2 instance in a different region) - SSH into your EC2 instance and navicate to the /var/www/html folder and run
npm install
(note you must have Node installed). This will install the proper node packages. - In the same /var/www/html folder you should now be able to run
node server.js
this will run the server on port 8000. - In your browser, navigate to the public DNS of your EC2 server and you should see the game running (Note: since this is running on an insecure URL (unless you buy a domain or setup a CDN), you must turn off your ad-blocker for the game. If the game does not work, you should be able to take a look at any console errors from the browser)
- Clone or download this repo
- Set the environment varialbe for OPENAI_API_KEY to your OpenAI API Key
- Ensure that
define('UseAWS', false);
is set at the top of the script.php file - Navigate to the repo folder and start an HTTP server (I used PHP - See https://www.php.net/manual/en/features.commandline.webserver.php for more details and https://www.php.net/manual/en/install.php for installation) then in your browser navigate to http://[localhost]:[port] of your local web server
- Create an EC2 server and install Apache (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateWebServer.html)
- Place the files from this repository in the /var/www/html folder
- Open up the necessary ports to your EC2 server (80 for HTTP and 443 for HTTPS)
- Create a secret in SSM Parameter store called OPENAI_API_KEY and set this to your OpenAI API Key
- Attach a role to your EC2 instance that allows access to this key
- Ensure that
define('UseAWS', true);
is set at the top of the script.php file and that the proper details are put into the $ssmClient creation (you likely will need to just change the region if you created your EC2 instance in a different region) - In your browser, navigate to the public DNS of your EC2 server and you should see the game running