Close
0%
0%

Python dev-server with RPi

How to make your own Python dev-server with Raspberry Pi

Public Chat
Similar projects worth following
It can do whatever you can imagine a normal Linux computer can do, such as browse the web, write code, edit documents, and connect to I/O devices such a thumb drive, mouse, keyboard, etc. This tutorial will be focused on learning how to make your own Python dev-server with Raspberry Pi.

A solid development environment is important. You need a place where you can look at your application to make sure it’s running fine. Many times folks do this on their local machine. It’s better to test on a separate machine from what you’re working on. This way, you can catch things like dependency and configuration changes.

This development/testing server has the following advantages:

  • A configuration and environment that matches production (if you have a Linux host)
  • Build code on any machine push it to a centralized location
  • Continuous Integration - Push and refresh in your browser

Ideally, you can set up a workflow that looks like this:

  1. Develop your code locally and commit it.
  2. Push to development and test it out
  3. Approve changes, push it live

This enables a great workflow where you can make changes and edits, commit, then push them and refresh your browser. You can then develop your code from any machine on the network that has git. Once you’re satisfied with the changes, you can copy the artifacts to production. In fact, you can integrate production pushes into this workflow to make it all automatic.

1.png

Terminal window after successfully connecting to the pi

Portable Network Graphics (PNG) - 120.91 kB - 05/09/2020 at 04:24

Preview
Download

2.png

Create and verify the project directory

Portable Network Graphics (PNG) - 24.45 kB - 05/09/2020 at 04:24

Preview
Download

3.png

Install flask

Portable Network Graphics (PNG) - 14.22 kB - 05/09/2020 at 04:24

Preview
Download

4.png

Navigate to project directory and create a new file

Portable Network Graphics (PNG) - 22.84 kB - 05/09/2020 at 04:24

Preview
Download

5.png

Start the remote server

Portable Network Graphics (PNG) - 70.31 kB - 05/09/2020 at 04:24

Preview
Download

View all 9 files

  • 1 × Raspberry Pi 3 or later version
  • 1 × Jumper wire
  • 1 × Computer

  • 1
    Step 0. Define the goal

    Before we begin, it is important to understand what is it that we are trying to build. By the end of the tutorial, you will be able to run a basic website (using Flask) off of a Raspberry Pi on your local home network.

    The goal of this tutorial is to demonstrate how a Pi can be used as a dev-server, more specifically, the example will be to host a simple website (using Flask).

  • 2
    Step 1. State the assumptions

    Here are some assumptions that this tutorial will make:

    1. You already have a Raspberry Pi set up with Raspbian OS. Here is a useful setup guide if you need one.
    2. The Pi is connected to your home WiFi (and that you know the Pi’s IP address).
    3. You will not require a screen going forward. assuming points 1 and 2 are complete.

    We will use VS Code with the Remote VSCode extension to remotely create and edit files on the Pi. I definitely recommend that you use these two to follow along. Also, these will make working with remote files a lot easier, so that’s a plus.

  • 3
    Step 2. Find the Pi’s IP address

    First, connect the Pi to a power supply, and ensure that it is correctly booted up and connected to the WiFi/Ethernet (basically, it needs to have an internet connection).

    We will use ssh to connect to and communicate with the Pi. To do that remotely using a laptop, you need to know its IP address. This can be easily obtained using your ISP’s admin portal (usually available at http://192.168.0.1. Please note that this could be different for different ISPs.)

    Usually, you should have your Pi connected to an address which may look similar to ‘192.168.0.12.’ Again, this will be different for different people. So please use the IP address that you found for your Pi in the admin portal. Going forward, this tutorial will use 192.168.0.12 as the Pi’s IP address.

View all 11 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates