Skip to content

uncle-lv/cgi-http-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CGI HTTP Server

license stars issues fork platform

Chinese | English

A CGI Web Server which is inspired by tiny-httpd and enhanced with the third-party libraries, libev, http-parser, hashmap, log.c. It shows you how a web server works briefly.

Functions

  • Parse HTTP request
  • Support GET, POST method
  • Support CGI
  • A simple logger

Usage

1.Install libev and Python3.

sudo apt install -y libev-dev python3

2.Pull the source code.

git clone https://github.com/uncle-lv/cgi-http-server.git

3.Into the directory src, and run make to compile the code.

make

4、Run CGI Server (the argument port is optional)

./server {port}

There are several urls for testing, /index.html/login.html and etc.

You should have the execute permission of CGI scripts.

Code Structure

src
├── hashmap.c
├── hashmap.h
├── http_parser.c
├── http_parser.h
├── http_request.c
├── http_request.h
├── log.c
├── log.h
├── Makefile
├── server
└── server.c

If you want to read the source code, please focus on http_request.* and server.c. The other files are third-party libraries.

hashmap: Hashmap implementation in C.

http_parser: HTTP request/response parser for C.

log.c: A simple logging library implemented in C99.

Contributions

Looking forward to Any issue or pull request from you.

Others

Maybe implement the whole HTTP/1.0 and CGI/1.1 in the future.

License

MIT

Thanks

About

a simple cgi HTTP server

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages