@@ -21,16 +21,21 @@ class Webapp:
2121
2222 Methods:
2323 - :meth:`Webapp.create`: Create a new webapp.
24+ - :meth:`Webapp.create_static_file_mapping`: Create a static file mapping.
2425 - :meth:`Webapp.reload`: Reload the webapp.
2526 - :meth:`Webapp.set_ssl`: Set the SSL certificate and private key.
2627 - :meth:`Webapp.get_ssl_info`: Retrieve SSL certificate information.
2728 - :meth:`Webapp.delete_log`: Delete a log file.
2829 - :meth:`Webapp.get_log_info`: Retrieve log file information.
30+
31+ Class Methods:
32+ - :meth:`Webapp.list_webapps`: List all webapps for the current user.
2933 """
34+ username = getpass .getuser ()
35+ files_url = get_api_endpoint (username = username , flavor = "files" )
36+ webapps_url = get_api_endpoint (username = username , flavor = "webapps" )
37+
3038 def __init__ (self , domain : str ) -> None :
31- self .username = getpass .getuser ()
32- self .files_url = get_api_endpoint (username = self .username , flavor = "files" )
33- self .webapps_url = get_api_endpoint (username = self .username , flavor = "webapps" )
3439 self .domain = domain
3540 self .domain_url = f"{ self .webapps_url } { self .domain } /"
3641
@@ -215,3 +220,14 @@ def get_log_info(self) -> dict:
215220 continue
216221 logs [log_type ].append (log_index )
217222 return logs
223+
224+ @classmethod
225+ def list_webapps (cls ) -> list :
226+ """List all webapps for the current user.
227+
228+ :returns: list of webapps info as dictionaries
229+ """
230+ response = call_api (cls .webapps_url , "get" )
231+ if not response .ok :
232+ raise PythonAnywhereApiException (f"GET webapps via API failed, got { response } :{ response .text } " )
233+ return response .json ()
0 commit comments