• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 Web Server- Mobile Huawei P20 does't work

Q&A Forum › Category: Other › ESP32 Web Server- Mobile Huawei P20 does't work
0 Vote Up Vote Down
Dattatraya Apte asked 4 years ago

Dear Sir,
 
I follwed exactly the same procedure / steps given in the tutorial. But I am getting the following errer.
 
exec(open(‘./main.py’).read(),globals())
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “<string>”, line 9, in <module>
NameError: name ‘socket’ is not defined
>>> r$

7 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
Can you tell me what is the project that you are following?
Regards,
Sara

0 Vote Up Vote Down
Dattatraya Apte answered 4 years ago

Hello World using muPycraft

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Did you upload both the boot.py and main.py files?
You’re probably getting that error because you haven’t uploaded the boot.py file.
Regards,
Sara

0 Vote Up Vote Down
Dattatraya Apte answered 4 years ago

Dear Madam, I Followed the same procedure. I have uploaded both main.py and booty.py files. But the resualt is as below – 
 
Ready to download this file,please wait!
……
download ok
exec(open(‘main.py’).read(),globals())
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “<string>”, line 9, in <module>
OSError: [Errno 98] EADDRINUSE
>>> {d

0 Vote Up Vote Down
Dattatraya Apte answered 4 years ago

Codesentered are as below –
 
Main.py 
 

Start your code here
# Complete project details at https://RandomNerdTutorials.com def web_page(): html = """<html><head><meta name="viewport" content="width=device-width, initial-scale=1"></head> <body><h1>Hello, World!</h1></body></html>""" return html s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 80)) s.listen(5) while True: conn, addr = s.accept() print('Got a connection from %s' % str(addr)) request = conn.recv(1024) print('Content = %s' % str(request)) response = web_page() conn.send('HTTP/1.1 200 OK\n') conn.send('Content-Type: text/html\n') conn.send('Connection: close\n\n') conn.sendall(response) conn.close()
---------------------------
booty.py

Start your code here
# Complete project details at https://RandomNerdTutorials.com #import socket import sys try: import usocket as socket except: import socket import network import esp esp.osdebug(None) import gc gc.collect() ssid = 'xxxxxxx' password = 'xxxxxx' help' station = network.WLAN(network.STA_IF) station.active(True) station.connect(ssid, password) while station.isconnected() == False: pass print('Connection successful') print(station.ifconfig())


0 Vote Up Vote Down
Dattatraya Apte answered 4 years ago

>>
>>>
Ready to download this file,please wait!
….
download ok
exec(open(‘boot.py’).read(),globals())
Connection successful
(‘192.168.1.104’, ‘255.255.255.0’, ‘192.168.1.1’, ‘192.168.1.1’)
>>>
Finaly I am succesful in getting IP Address. But it is not displaying web page in browser

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
You need to upload both files to the board.
First, upload the boot.py.
Then, the main.py.
After that, press the RST button.
If you’re using upyCraft IDE, on the left bard, you should see the files uploaded to the board under the device folder.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.