 Complete the following phrase:  In 661 Naples, with the permission of the emperor Constans II, was ruled by a local duke, Basilius, whose allegiance to the emperor soon became merely nominal. In 763 the duke Stephen II switched his allegiance from Constantinople to the Pope. In 840 Duke Sergius I made the succession to the duchy hereditary, and thenceforth Naples was de facto totally independent. At this time the city was mainly a military centre, ruled by an aristocracy of warriors and landowners, even though it had been forced to surrender to the neighbouring Lombards much of its inland territory. Naples was not a merchant city as were other Campanian sea cities such as Amalfi and Gaeta, but had a respectable fleet that took part in the 