LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-17-2017, 12:42 PM   #1
zvivered
Member
 
Registered: Sep 2007
Posts: 294

Rep: Reputation: 23
simple HTTP server for linux


Hello,

I have to develop a very simple HTTP server running under embedded Linux.

The server gets HTTP requests, reads information from the target and send it back to the client.

Security/Encryption is not required.

Can you provide a simple code sample ?

Thank you,
Z.V
 
Old 02-17-2017, 12:53 PM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
I saw one http server written in Bash recently. However, writing a web server is kind of the "Hello, World!" of networking. Have you tried searching for http servers in your favorite search engine? Here's an old list:

https://gist.github.com/willurd/5720255

But rather than cargo-culting it, you might want to read the HTTP specification and just implement that.

https://tools.ietf.org/html/rfc7230
https://tools.ietf.org/html/rfc2616
 
1 members found this post helpful.
Old 02-17-2017, 01:16 PM   #3
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by zvivered View Post
Hello,

I have to develop a very simple HTTP server running under embedded Linux.

The server gets HTTP requests, reads information from the target and send it back to the client.

Security/Encryption is not required.

Can you provide a simple code sample ?

Thank you,
Z.V
Why? Is there a gun to your head? Do "they" have your children?
 
Old 02-17-2017, 01:25 PM   #4
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,138
Blog Entries: 6

Rep: Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827
Python has a couple examples.

Simple http server:
Code:
python2 -m SimpleHTTPServer 8000
Code:
python3 -m http.server 8000
Open web browser to http://127.0.0.1:8000/
 
1 members found this post helpful.
Old 02-17-2017, 01:27 PM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
This is a request to write a custom program for you. No one is going to do that. You should hit up a freelancer site.

Unless you mean to use simple python http server or Netcat or something.
 
1 members found this post helpful.
Old 02-17-2017, 01:59 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by zvivered View Post
Hello,
I have to develop a very simple HTTP server running under embedded Linux. The server gets HTTP requests, reads information from the target and send it back to the client. Security/Encryption is not required.

Can you provide a simple code sample ?
You've been here TEN YEARS now; you should have read the LQ Rules and "Question Guidelines" at this point, and know that this isn't the place to come for handouts. We will be happy to HELP you if you have an actual problem, but don't ask us to write your code or look things up for you....Google can give you links to many samples.

Further, you've received answers and been asked questions over the years, but haven't followed up in many of your threads.

Last edited by TB0ne; 02-17-2017 at 02:00 PM.
 
Old 02-17-2017, 02:36 PM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
i've seen op's*other thread and understand the suspicions.
however this question here i find valid (assuming they're asking existing software).
but it also has been answered already: click the gist in post #2.
 
Old 02-17-2017, 02:41 PM   #8
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
I don't think its really answered though -

Quote:
The server gets HTTP requests, reads information from the target and send it back to the client.
That is a bit more than running apache, simplehttp, or anything like that. In my mind, to do it correctly, that is going to require a program. AND its going to require explaining what the user means by 'information', 'target', and 'client'.

If the request was 'serving up a text file' or 'serving up the directory' then I would agree that those small web servers in the gist would be good answers.

Last edited by szboardstretcher; 02-17-2017 at 02:43 PM. Reason: My damn E key is sticking today
 
Old 02-17-2017, 02:46 PM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
ok i guess this is above my paygrade.
i assumed that this:
Quote:
Originally Posted by zvivered View Post
The server gets HTTP requests, reads information from the target and send it back to the client.
is the definition of server:
get request from me: hey, i want website.
read information from target - the target being an html document.
send it back to the client - send the content of the html doc back to the client.

i guess i'm wrong then.

Last edited by ondoho; 02-17-2017 at 02:48 PM.
 
Old 02-17-2017, 02:59 PM   #10
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
I might look to the distro packages for solutions first. Some dependencies may be huge.

Lighttpd might be used but there are some command line ones out there. https://www.linux.com/news/which-lig...rver-right-you

nweb.c might work.

Wonder if netcat (nc) or even ftp would do??
 
Old 02-17-2017, 05:31 PM   #11
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
You could use node: https://www.npmjs.com/package/node-http-server
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Running a simple HTTP web server with one terminal command and python LXer Syndicated Linux News 0 05-11-2016 09:20 AM
[SOLVED] HTTP::Server::Simple::CGI under Slackware 12 ? czezz Slackware 4 11-26-2014 04:29 PM
netcat as simple http server (or just prints a message) ezekieldas Linux - Networking 1 06-02-2012 02:36 PM
LXer: Start Simple HTTP Server with Python LXer Syndicated Linux News 0 09-24-2009 12:40 PM
LXer: Tech Tip: Really Simple HTTP Server with Python LXer Syndicated Linux News 0 09-22-2009 08:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration