Next, use the following command to start editing the newly created app.py file. Now, press F1 and choose ‘Remote Start Server.’ This should allow you to remotely edit files on the Pi using your laptop. Navigate to project directory and create a new file On checking the directory using the ‘ls’ command, you should be able to see this newly created file. Now, create your first code file (app.py) using the following command: touch app.py First, navigate to your newly created project directory (from step 4) by using the following command: cd MyFlaskWebsiteĪll project files and folders will reside inside this ‘MyFlaskWebsite’ directory. Now that Flask is installed, we can start creating files and writing some code. Use the following command to install flask on the Pi: sudo apt-get install python3-flask Install flask Step 6. It uses Jinja (Python based template engine) as its template engine which makes it very usable and powerful. Flask is a Python based micro web framework. We will use Flask to create a simple website. Create and verify the project directory Step 5. Use the ‘ls’ command to verify that you can indeed see a new folder named MyFlaskWebsite. Use the following command to create the directory: mkdir MyFlaskWebsite Let’s create a directory for the website we wish to build. You should now be in the home directory of the Pi. Terminal window after successfully connecting to the pi Step 4. You may be prompted to change your default password. If this is the first time you are connecting to the Pi, use raspberry as the password. Connect to the Pi with an IP address of 192.188.0.12 using the following ssh command: ssh -R 52698:localhost:52698 above command will set up a 2-way communication channel between your laptop and the Pi. Open VS Code and its built-in terminal window on your laptop. Going forward, this tutorial will use 192.168.0.12 as the Pi’s IP address. So please use the IP address that you found for your Pi in the admin portal. 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. Please note that this could be different for different ISPs.) This can be easily obtained using your ISP’s admin portal (usually available at. To do that remotely using a laptop, you need to know its IP address. We will use ssh to connect to and communicate with the Pi. Find the Pi’s IP addressįirst, 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). Also, these will make working with remote files a lot easier, so that’s a plus. I definitely recommend that you use these two to follow along. We will use VS Code with the Remote VSCode extension to remotely create and edit files on the Pi.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |