Код: Выбрать все
# boot.py
from time import sleep
ssid_ = 'Gansta-Paradise.guest'
wp2_pass = ''
def do_connect():
import network
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print('connecting to network...')
sta_if.active(True)
sta_if.connect(ssid_, wp2_pass)
while not sta_if.isconnected():
pass
print('network config:', sta_if.ifconfig())
do_connect()
sleep(3)
import page
page.app.run(debug=True, host = sta_if.ifconfig())
page.py
Код: Выбрать все
import picoweb
import test
html = """<!DOCTYPE HTML>
<html lang = "ru">
<head>
<meta charset = "utf-8" >
<title> Gansta ESP32 PICO Core </title>
</head>
<body>
<p> Hello World!!! </p>
<p> <b> Hello World in Bold!!! </b> </p>
<form method="get" action="/mbtn">
<input type="submit" value="START" name="mbtn" />
</form>
</body>
</html>"""
app = picoweb.WebApp(__name__)
@app.route("/")
def index(req, resp):
yield from picoweb.start_response(resp,content_type = "text/html")
yield from resp.awrite(html)
@app.route("/mbtn")
def btn(req, resp):
yield from picoweb.start_response(resp,content_type = "text/html")
test.migo()
yield from resp.awrite(html)
app.run(debug=True, host = "192.168.1.125")
test.py
Код: Выбрать все
#print ("Hello world from script")
import machine
import utime
import network
#sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
#sta_if.scan()
#sta_if.connect("Gansta-Paradise.guest", "")
pin13 = machine.Pin(2,machine.Pin.OUT)
def migo():
print("test")
pin13.value(1)
utime.sleep_ms(500)
pin13.value(0)
utime.sleep_ms(500)
IDE
https://dfrobot.gitbooks.io/upycraft/content/
Код: Выбрать все
import picoweb
import picoweb
html = """<!DOCTYPE HTML>
<html lang = "ru">
<head>
<meta charset = "utf-8" >
<title> Picoweb on ESP32 PICO Core </title>
</head>
<body>
<p> Hello World!!! </p>
<p> <b> Hello World in Bold!!! </b> </p>
<button>ЖМИ</button>
</body>
</html>"""
app = picoweb.WebApp(__name__)
@app.route("/")
def index(req, resp):
yield from picoweb.start_response(resp,content_type = "text/html")
yield from resp.awrite(html)
app.run(debug=True, host = "192.168.1.113")