This repository contains the project files, source code and compiled binaries for a basic web server that can be deployed through Resin.io.
This is not an example on how to build web-servers, but rather on how to add web-service features to some other project. For instance, if you had a temperature logger and wanted to be able to respond to web requests and return the current temperature.
- Raspberry Pi or Raspberry Pi 2 with power, networking, and an SD card
- An installation of mono-complete on Windows, OSX, or Linux
- If you haven't got a Resin.io account, visit resin.io and sign up.
- Start a new applicaton on Resin.io and follow the directions for your target device type to load the image onto your SD card.
- Insert the SD card into the Raspberry Pi, power it up and wait for it to connect to the internet and resin.io.
- After about 10 minutes your new device should show up on your application dashboard.
You can deploy the unaltered example code just to see it run on your device. To do so, follow these steps...
- Clone the WebServer repo:
$ git clone https://github.com/ResinIoDotNetExamples/Example-02-WebServer.git
Add the resin remote. You can find an example of this command and and a copyable link with your username and application name by clicking on your application on the resin.io dashboard. The information you need is at the top right next to the Need Help? button:
$ git remote add resin [email protected]:<yourUserName>/<yourApplicationName>.git
And finally push the code to your Raspberry Pi:
$ git push resin master
After deployment is complete, go to the resin.io dashboard; select your application; select your test device; and click on "Logs". At the end of the deployment process, you should see log entries showing that your web server has started up and showing that three 'content services' have been installed.
- On the resin.io dashboard, click on your app.
- Click on your device
- Note the IP address
- Open a web browser and enter http://XX.XX.XX.XX:8080/ replacing the XX's with the IP address from the previous step.
- You should see a "Hello World" message.
- Now try http://XX.XX.XX.XX:8080/time and you should see the current UTC time.
The process is the same as for Example-01, except that you also need to choose "Mono / .NET 4.5" as the target runtime. To do so, right click on the project and select Options. Under Build, select "General" and select "Mono / .NET 4.5" as the target runtime. This will enable use of the .Net 4.5 async semantics and Task-based scheduling, which makes much more efficient use of your CPU resources.