Spaces:
Sleeping
Sleeping
| import requests | |
| import json | |
| import pandas as pd | |
| DictionaryOfTemplates={ | |
| '1.0 substructure': [], | |
| '2.1 frames' : [], | |
| '2.2 upper floor':[], | |
| '2.3 roof':[], | |
| '2.4 stairs':[], | |
| '2.5 external walls':[], | |
| '2.6 external openings':[], | |
| '2.7 internal walls':[], | |
| '2.8 internal openings':[], | |
| '3.1 wall finishes':[], | |
| '3.2 floor finishes':[], | |
| '3.3 ceiling finishes':[], | |
| '4.0 fittings, furnishings and equipments':[], | |
| '5.0 services':[], | |
| '5.1 sanitary':[], | |
| '7.0 works to existing buildings':[], | |
| '8.1 site preparation works':[], | |
| '8.2 roads, paths, pavings':[], | |
| '8.3 soft landscaping':[], | |
| '8.4 fencing, railing, walls':[], | |
| '8.5 external fixtures':[], | |
| '8.6 external drainage':[], | |
| '8.7 external services':[], | |
| '8.8 minor buildings':[] | |
| } | |
| def APIValues(): | |
| query={"loginname":"adr","password":"Tameen"} | |
| #token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiQURSIiwibmJmIjoiMTY4MDg1OTgzMyIsImV4cCI6IjE2ODA5MDMwMzMifQ.-FULhKD_M-cyIdSMMIYDlEo9DoZtc00yIlyXIPuyLZI" | |
| head={'Content-Type':'application/json'} | |
| url = "https://httpbin.org/post" | |
| response=requests.post(url="https://consoletest.trevorsadd.co.uk/account/login",json=query,headers=head) | |
| key=response.text #token generated | |
| head={'Content-Type':'application/json;charset=UTF-8',"Authorization":'Bearer {}'.format(key)} | |
| data={"pagesize": 1000000000} | |
| response=requests.post(url=" https://consoletest.trevorsadd.co.uk/template/getgridview?isarchive=false",json=data,headers=head) | |
| dict1=response.json() | |
| return dict1 | |
| def RetrieveMC_Templates_API(): | |
| # threading.Timer(600.0,update_df).start() | |
| global DictionaryOfTemplates | |
| dict1=APIValues() | |
| for item in dict1.get('data') : | |
| section=item.get('section').lower() | |
| if section in DictionaryOfTemplates.keys(): | |
| if item.get('templatename') not in DictionaryOfTemplates[section]: | |
| DictionaryOfTemplates[section].append([item.get('templatename'),item.get('unit')]) | |
| # print(json.dumps(DictionaryOfTemplates, indent=4)) | |
| return DictionaryOfTemplates |