Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

HTTP server library and example


  • Please log in to reply
2 replies to this topic

#1 Nart Schinackow

Nart Schinackow

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationLondon

Posted 27 August 2012 - 10:06 AM

Hello all, This is an HTTP server library that contains all functions that handles http web requests (GET /)(only), the server listens for connections on a separate thread hence not affecting the netduino main loop(multi task). how to use the example: 1)pick a 2gb sd card and put files in it (html,pictures(jpeg,gif),flash pages(with its swf) 2)insert the sd card into netduino-plus 3)start visual studio 2010 express 4)open the example project 5)compile it and deploy to your netduino-plus board 6)wait until ip address appears in the debug window 7)open your browser and type in the ip address 8)the list of files in the sd card will appear as a link each, choose a file and it will reply with its contents. note: you could import your own html files into sd card so that when clicked an html webpage will be displayed note: the zipped file contains a documentation that provides help and description on the library

Attached Files



#2 kevintechie

kevintechie

    New Member

  • Members
  • Pip
  • 2 posts

Posted 21 November 2012 - 08:25 AM

Thanks for your work on this code, Nart. It's much better than many other Netduino HTTP servers out there. I do have a few suggestions to make it better. It's common for web developers to create an index.htm or index.html file. If you just match on "index" to display the index.txt file, the server will return the text file even if there is an index.htm or index.html. You could change the string used to trigger the display of the index.txt file from "index" to "index.txt". Perhaps it is better to remove it altogether as it seems unnecessary. When a specific resource is not requested, (e.g.: www.mysite.com or www.mysite.com/somedirectory/ ), it is common to send a default page (if it exists) rather than a file list. The most common file names for static content are index.html, index.htm, and default.htm. You could either hard code these typical default names or add the ability to override or append to the default list when the server is instantiated. It's important to return a 404 Not Found HTTP response code rather than a 200 OK when a resource is not found. It makes it difficult to debug coding errors if bad requests return a 200 code. It can also cause problem with caching. It may take a bit of refactoring to accomplish the response code change. Looking at the code, I was unclear why you create the index.txt file when the server is instantiated and then overwrite it on each request for "" or "index" resources. It seems like it may be faster (and friendlier to the SD card) to use the index.txt file as a template and inject the file list at response time. This would enable the user to customize the index.txt file in addition to the notfound.txt file. Many people like to be able to disable the file list feature when a specific resource is not requested. This could be added as a constructor parameter feature as well. Thanks again for your library and thanks for considering these enhancements. (K)

#3 Nart Schinackow

Nart Schinackow

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationLondon

Posted 22 December 2012 - 01:36 AM

Hello kevintechie, well thanks for looking into my library and your interest :) i will do as you requested :) check out my new website www.softelectrotech.com which will contain all my future releases :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.