https://github.com/terance-edmonds/python-web-server
A simple web server developed with python sockets.
https://github.com/terance-edmonds/python-web-server
python socket-programming webserver
Last synced: about 1 year ago
JSON representation
A simple web server developed with python sockets.
- Host: GitHub
- URL: https://github.com/terance-edmonds/python-web-server
- Owner: terance-edmonds
- Created: 2023-08-30T18:47:42.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-09-12T02:39:20.000Z (almost 3 years ago)
- Last Synced: 2025-01-16T02:49:30.349Z (over 1 year ago)
- Topics: python, socket-programming, webserver
- Language: Hack
- Homepage:
- Size: 147 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
Awesome Lists containing this project
README
# Simple Python Web Server (Socket Programming)
This is a simple web server developed with python sockets. Server is compatible of serving various file types and also supports serving multiple clients at once.
The server also support simple GET and POST form submissions.
## Example links
| Type | Route |
| --------- | ------------------------------------------------------------------- |
| **.html** | [/](http://localhost:2728/) |
| **.php** | [/contact.php](http://localhost:2728/contact.php) |
| **.css** | [/style.css](http://localhost:2728/sample/style.css) |
| **.js** | [/script.js](http://localhost:2728/sample/script.js) |
| **.jpg** | [/images/parallax1.jpg](http://localhost:2728/images/parallax1.jpg) |
| **.json** | [/files/sample.json](http://localhost:2728/files/sample.json) |
| **.xml** | [/files/sample.xml](http://localhost:2728/files/sample.xml) |
| **.txt** | [/files/sample.txt](http://localhost:2728/files/sample.txt) |
| **.pdf** | [/files/sample.pdf](http://localhost:2728/files/sample.pdf) |
| **.xlsx** | [/files/sample.xlsx](http://localhost:2728/files/sample.xlsx) |
## Requirements
- PHP 8.2.4 or up ( `php -v` for version )
- Python3 ( `python -v` for version )
- NodeJs (`node -v` for version ) [ optional ]
## Usage
Create a folder named as `htdocs` in the root directory, and add the web files to it.
Than, to start the server, Run the below code.
```bash
python serve.py
```
**For Development**
If you have `NodeJs` installed, use npm and nodemon to start the server.
```bash
npm install # install node modules
```
To run the server
```bash
npm start # run the server
```
```bash
npm run dev # run the server in development mode
```
Now open the browser and head over to [localhost:2728](http://localhost:2728).