0

Ok, obviously I am new at this. I got this Python traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 30
SyntaxError: invalid syntax

What does File "<string>" stand for?

My code contains an empty line @ line 30, so I'm assuming this doesn't refer to my code, but what DOES it refer to?

( I'm using Micropython on an ESP8266 )

This is my code:

import network
import tinyweb
import machine

# Connect to your WiFi AP
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect('blabla', 'blabla')

# Create web server application
app = tinyweb.webserver()
count = 0

# Hello world index page (just to be sure - let's handle most popular index links)
@app.route('/')
@app.route('/index.html')
async def index(req, resp):
    await resp.start_html()
    await resp.send('<html><body><h1>Hello, world!</h1></html>\n')

# Counter REST API endpoint
@app.resource('/counter')
def counter(data):
    return {'name': 'Foo', 'counter': counter}

def pin_handler(p)
    global count
    count =count + 1

#pin=machine.Pin(0, machine.Pin.IN, machine.Pin.PULL_UP)  
#pin.irq(handler = pin_handler, trigger = Pin.IRQ_FALLING, hard = True)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=80)
Bigman74066
  • 408
  • 4
  • 12

1 Answers1

0

Thanks to buran I found the cause. The <string> apparently DOES just refer to my own code. I forgot to add a colon at the and of the pin_handler function and that somehow shifted the position the error occured downwards...

Bigman74066
  • 408
  • 4
  • 12