Skip to content

Commit

Permalink
feat:more file support
Browse files Browse the repository at this point in the history
  • Loading branch information
nsavinda committed Sep 15, 2023
1 parent 21dca49 commit 1e98db2
Show file tree
Hide file tree
Showing 14 changed files with 306 additions and 387 deletions.
Binary file removed 21001792.zip
Binary file not shown.
247 changes: 0 additions & 247 deletions 21001792/21001792/server.py

This file was deleted.

10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ python server.py
Put your files to htdocs folder






# About

- Support for POST and GET requests
Expand All @@ -34,6 +30,12 @@ Put your files to htdocs folder
│ ├── index.php # Form
│ ├── add.php # Php code to add numbers
│ ├── image.jpg # Image
| ├── form.html
| ├── favicon.ico
| ├── 1/
| | ├── add.php
| | ├── image.png
| | ├── index.php
|
├── server.py # Main File
```
Expand Down
16 changes: 16 additions & 0 deletions htdocs/1/add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<body>
<?php

if (isset($_POST['n1']) && isset($_POST['n2']))
echo $_POST['n1'] + $_POST['n2'];
else
echo "empty";


if (isset($_GET['n1']) && isset($_GET['n2']))
echo $_GET['n1'] + $_GET['n2'];
?>

</body>
</html>
Binary file added htdocs/1/image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions htdocs/1/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: Arial, sans-serif;
background-image: url('image.jpg'); /* Replace 'your-image-url.jpg' with the actual URL or path to your image */
background-size: cover; /* This will cover the entire background */
background-repeat: no-repeat; /* Prevent image from repeating */
background-attachment: fixed;
}
form {
width: 350px;
margin: 0 auto;
padding: 30px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
}
input[type="text"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 3px;
}
input[type="submit"] {
background-color: #007bff;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 3px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<form action="add.php" method="post">
<input type="text" name="n1" placeholder="Enter number 1" />
<br>
<input type="text" name="n2" placeholder="Enter number 2" />
<br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Binary file removed htdocs/Visitor.png
Binary file not shown.
52 changes: 42 additions & 10 deletions htdocs/add.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
<!DOCTYPE html>
<html>
<body>
<?php
<head>
<title>Calculator</title>
</head>
<body>
<h1>Simple Calculator</h1>

if (isset($_POST['n1']) && isset($_POST['n2']))
echo $_POST['n1'] + $_POST['n2'];
else
echo "empty";
<?php
$result = "";

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['n1']) && isset($_POST['n2'])) {
$n1 = floatval($_POST['n1']);
$n2 = floatval($_POST['n2']);
$result = $n1 + $n2;
} else {
$result = "Empty";
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($_GET['n1']) && isset($_GET['n2'])) {
$n1 = floatval($_GET['n1']);
$n2 = floatval($_GET['n2']);
$result = $n1 + $n2;
} else {
$result = "Empty";
}
}
?>

<form method="post" action="calculator.php"> <!-- Replace "calculator.php" with the actual filename of this HTML file -->
<label for="n1">Number 1:</label>
<input type="text" name="n1" id="n1" required>
<br>
<label for="n2">Number 2:</label>
<input type="text" name="n2" id="n2" required>
<br>
<input type="submit" value="Add">
</form>

if (isset($_GET['n1']) && isset($_GET['n2']))
echo $_GET['n1'] + $_GET['n2'];
?>
<?php
if (!empty($result)) {
echo "Result: " . $result;
}
?>

</body>
</html>
</html>
Binary file removed htdocs/command.png
Binary file not shown.
Binary file added htdocs/favicon.ico
Binary file not shown.
Loading

0 comments on commit 1e98db2

Please sign in to comment.