Commit 5dca0c1c authored by Bradon Ladd's avatar Bradon Ladd

Merge branch 'laddbr/lab06' into 'master'

Laddbr/lab06 to Master

See merge request !6
parents fcf543c3 78e203bd
Pipeline #20952 passed with stages
in 3 minutes and 17 seconds
File added
#!/bin/bash
cd code
docker-compose up --build
docker cp gcc:/usr/src/code/area ..
docker-compose down
cd ../web
cp ../area ./cgi-bin/
docker-compose up --build
cd ..
\ No newline at end of file
FROM gcc:10.2.0
COPY . /usr/src/code
WORKDIR /usr/src/code
RUN g++ -std=c++20 -o area areaMain.cpp areaFunction.cpp
\ No newline at end of file
#ifndef AREA_AREAFUNCTION_H_
#define AREA_AREAFUNCTION_H_
#include "areaFunction.h"
float areaOfSquareWithSides(float side) { return side * side; }
float areaOfCircleWithRadius(float radius) {
return (3.14 * (radius * radius));
}
#endif // AREA_AREAFUNCTION_H_
#ifndef AREA_AREAFUNCTION_H_
#define AREA_AREAFUNCTION_H_
float areaOfSquareWithSides(float side);
float areaOfCircleWithRadius(float radius);
#endif // AREA_AREAFUNCTION_H_
#include "areaFunction.h"
#include <cstring>
#include <iostream>
#include <stdlib.h>
int main(int argc, char *argv[]) {
char *s = std::getenv("QUERY_STRING");
if (s == nullptr || strlen(s) < 3 || s[0] != 's' || s[1] != '=') {
std::cerr << "Usage: QUERY_STRING=\"s=N\" area" << std::endl;
return 1;
}
s += 2; // advance the string pointer beyond "s=" to point to the number
// "atoi()" is C++'s method of converting a string to an integer
float argument = atof(s);
if (argument == 0) {
std::cout << "Value must be an integer above 0" << std::endl;
return 1;
}
s += 4;
std::string name = s;
if (strlen(s) == 0) {
name = "user";
}
float squareArea = areaOfSquareWithSides(argument);
float circleArea = areaOfCircleWithRadius(argument);
std::cout << "Content-type: text/html;\n\n"
"<!doctype html>\n"
"<html itemtype=\"http://schema.org/WebPage\" lang=\"en\">\n"
"<head><meta charset=\"UTF-8\">\n"
"<title>Area Calculator Results</title>"
"</head>"
"<body>"
"<p>The area of a square with sides of "
<< argument << " units is " << squareArea
<< " units.</p>"
"<p>The area of a circle with radius of "
<< argument << " units is " << circleArea
<< " units.</p>"
"<p>Thank you for entering a value, "
<< name << ".</p>"
"<p><a href=\"/\">Home</a></p>"
"</body>"
"</html>"
<< std::endl;
return 0;
}
version: '3'
services:
gcc:
build:
context: .
dockerfile: Dockerfile
container_name: gcc
\ No newline at end of file
FROM httpd:2.4
COPY ./public-html/ /usr/local/apache2/htdocs/
COPY ./cgi-bin/ /usr/local/apache2/cgi-bin/
COPY ./my-httpd.conf /usr/local/apache2/conf/httpd.conf
\ No newline at end of file
#!/bin/bash
# disable filename globbing
set -f
echo "Content-type: text/plain; charset=iso-8859-1"
echo
echo CGI/1.0 test script report:
echo
echo argc is $#. argv is "$*".
echo
echo SERVER_SOFTWARE = $SERVER_SOFTWARE
echo SERVER_NAME = $SERVER_NAME
echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE
echo SERVER_PROTOCOL = $SERVER_PROTOCOL
echo SERVER_PORT = $SERVER_PORT
echo REQUEST_METHOD = $REQUEST_METHOD
echo HTTP_ACCEPT = "$HTTP_ACCEPT"
echo PATH_INFO = "$PATH_INFO"
echo PATH_TRANSLATED = "$PATH_TRANSLATED"
echo SCRIPT_NAME = "$SCRIPT_NAME"
echo QUERY_STRING = "$QUERY_STRING"
echo REMOTE_HOST = $REMOTE_HOST
echo REMOTE_ADDR = $REMOTE_ADDR
echo REMOTE_USER = $REMOTE_USER
echo AUTH_TYPE = $AUTH_TYPE
echo CONTENT_TYPE = $CONTENT_TYPE
echo CONTENT_LENGTH = $CONTENT_LENGTH
\ No newline at end of file
version: '3'
services:
web:
build:
context: .
dockerfile: Dockerfile
container_name: web
ports:
- 80:80
\ No newline at end of file
This diff is collapsed.
<!doctype html>
<html itemtype="http://schema.org/WebPage" lang="en">
<head><meta charset="UTF-8">
<title>Area Calculator Form</title>
</head>
<body>
<form action="/cgi-bin/area" method="get">
<label for="side">Side:</label>
<input type="text" id="side" name="s">
<label for="name">Name:</label>
<input type="text" id="name" name="n">
<button type="submit">Calculate</button>
</form>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment