Skip to content

W3bS3rv3r/webserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webserver

This project was developed by supermeia and Lucas Fads

Specs

This project aims to repdroduce some of nginx's behavior.

The webserver implements the following functionalities:

  • Serves a fully static website;
  • Has GET, POST and DELETE methods;
  • Interfaces with Python cgi for POST and GET methods.

Config

Through the config file you can set the following functionalities:

  • Chose the port of a server;
  • Setup the server_name;
  • Limit client body size;
  • Setup routes (no regexp);
    • Define accepted methods for that route;
    • Define HTTP redirection;
    • Define the root directory (where files will be served from);
    • Turn directory listing on/off
    • Set an index file;
    • Execute cgi based on file extension (.py for example);
    • Configure where uploaded files will be stored.

Testing the webserver

This webserver was tested using the firefox browser during development and it only runs on linux.

To run the webserver on your machine follow these steps:

  1. Make sure you have python and make installed:
make -v; python3 --version

If the command above doesn't return any error messages you're good to go!

  1. Clone this repo on your machine:
git clone https://github.com/W3bS3rv3r/webserver
  1. Enter the repository and compile the program
cd webserver && make
  1. change the paths of the config files to match the path of your machine:
sed -i 's|demo_path|'"$(pwd)"'|g' www_demo.conf &&
sed -i "s|home|$HOME|g" default.conf
  1. Run the server with the demo config and then open http://localhost:4343/ on your browser to see it in action:
./webserv www_demo.conf
  1. To stop the program just hit Control-C