Created
September 17, 2017 19:28
-
-
Save mcihad/2a6101956f3dd56a9bad97f3718e156c to your computer and use it in GitHub Desktop.
N11 CityService Kullanımı
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template | |
from suds.client import Client | |
app = Flask(__name__) | |
class CityService(object): | |
__cities = [] | |
__loaded = False | |
__wsdl = "https://api.n11.com/ws/CityService.wsdl" | |
def __init__(self, WSDL="https://api.n11.com/ws/CityService.wsdl"): | |
self.__wsdl = WSDL | |
self.service = Client(WSDL).service | |
def getCities(self): | |
if not self.__loaded: | |
for city in self.service.GetCities()["cities"]["city"]: | |
self.__cities.append( | |
{ | |
"cityName": city["cityName"], | |
"cityId": city["cityId"], | |
"cityCode": city["cityCode"] | |
} | |
) | |
self.__loaded = True | |
return self.__cities | |
cityService = CityService() | |
@app.route("/") | |
def index(): | |
return render_template("cities.html", cities=cityService.getCities()) | |
if __name__ == '__main__': | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment