Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

# Node.js dependencies:
node_modules/
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.7

RUN apt-get update

RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs

WORKDIR /app

COPY . /app

RUN apt-get install python3-pip -y
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt

RUN rm -rf node_modules/*
RUN npm install

EXPOSE 8080

CMD ["npm", "start"]
2 changes: 2 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
runtime: custom
env: flex
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require('express');
const python = require('python-shell');

const app = express();
const PORT = process.env.PORT || 3000;
const PORT = process.env.PORT || 8080;

app.use(express.static('public'));
app.use(express.json());
Expand All @@ -21,10 +21,12 @@ app.post('/math', (req, res) => {

const option = {
args: [input, isRad, isBinary],
scriptPath: '/app/',
// args: [input, isRad, isBinary, isBinaryInput],
};

// TODO change to always listening python shell instead of creating and deleting everytime
const pyPath = path.join('', 'calculate.py');
/* eslint-disable-next-line */
const pyshell = new python('calculate.py', option);

Expand Down
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function createWindow() {
});

window.loadURL('http://localhost:3000/');
window.loadFile('./public/index.html');
}

app.on('ready', createWindow);
Expand Down
2 changes: 1 addition & 1 deletion public/serverScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function calc() {
dlist.appendChild(option);

// calls node to perform the calculation over the route
const response = await fetch('http://localhost:3000/math', {
const response = await fetch('/math', {
method: 'POST',
body: JSON.stringify(input),
headers: {
Expand Down