• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomepcDuinoHow to use Python to setup pcDuino as a web server
Previous Next

How to use Python to setup pcDuino as a web server

Posted by: admin , January 13, 2015

In this tutorial, we are going to use Python to setup pcDuino as a we b server:

 

1. Install Requests (Requests is a HTTP client library of Python)

  1. $ sudo apt–get install python–requests

2. Install python-pip (python-pip is a tool used to install and manage python software package)

  1. $sudo apt–get install python–imaging python–imaging–tk python–pip python–dev git

Note: If the above command failed, please run the following command first:

  1. $sudo pip install flask

3. Install Flask (Flask is a light weight web application framework written in Python):

  1. $sudo pip install flask

4. Sample code:

  1. from flask import Flask
  2. app = Flask(__name__)
  3. @app.route(“/”)
  4. def hello():
  5. return ” Welcome to pcDuino ! “
  6. if __name__ == “__main__”:
  7. app.run(host=‘0.0.0.0’, port=80, debug=True)

Save the above code to a file named hello-flash.py, and run “sudo python ./helleo-flash.py”:

python_webservefr_2

5. Use ‘ifconfig’ command to find out the IP address of pcDuino:

python_webservefr_3

 

6. On another PC or iPad that shares the same router, open a web browser, and input 192.168.1.35:

python_webservefr_4

 

You can see that it works! At the same time, on pcDuino’s terminal, the following message will display:

 

python_webservefr_5

 

Share!
Tweet

admin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors