Package: asita
What is Asita ?Asitais aweb application framework for python. It is designed to be easy to use and be more easy forjavascript usersto use python frameworks because it is based onexpress-js framework.How to install Asita ?Install this package usingpip$ pip install asitaDocumentationGet startedExemplefromasitaimportApplication# creating application instanceapp=Application()# callback when web server is readydeflisten_callback(error):iferror:raiseerrorprint(f"Server listening on port 1000.")# listen the webserver on port (for instance port 1000)app.listen(1000,lambdaerror:listen_callback(error))ApplicationclassMethodsNameParametersDescriptionall(path,callback)path:string, callback:functionRoutes an HTTP request, whereallis the HTTP method such as GET, PUT, POST, OATCH, DELETE, HEADpost(path,callback)path:string, callback:functionRoutes HTTP POST requestsget(path,callback)path:string, callback:functionRoutes HTTP GET requestsput(path,callback)path:string, callback:functionRoutes HTTP PUT requestspatch(path,callback)path:string, callback:functionRoutes HTTP PATCH requestsdelete(path,callback)path:string, callback:functionRoutes HTTP DELETE requestshead(path,callback)path:string, callback:functionRoutes HTTP HEAD requestsdefine_asset(name,directory)name:string, directory:stringDefine the asset directory accesslisten(port,callback)port:integer, callback:functionstart listening a portCreate a routeExemple# some awesome things check request and response methods :-)defhome(request,response):pass# "/" is the default pathapp.all("/",lambdareq,res:home(req,res))To see more example, check the example file.RequestclassAttributsNameDescriptionheadersheaders of the requestsessionclient sessionpaththe url's pathrequest_typetype of requestserver_addressaddress of the requested serverserver_versionversion of the requested serverprotocol_versionversion of the HTTP protocolbodythe body content of the POST requestqueryurl paramsMethodsNameParametersDescriptionget(value)value:stringget a header of the requestaccepts()noneget types which are acceptedResponseclassMethodsNameParametersDescriptionstatus(code)code:HttpResponsesreturn the response's stateset_header(key,value)key:string, value:stringadd/update headerssend(data,type?,encoded?)data:object, type:string, encoded:boolean, is_asset:booleansend responsejson(data)data:dictwrite json on a pagerender(path)path:stringrenderhtmlfile.end()nonestop the current request?means that it is optionnalSessionsclassNameParametersDescriptionadd()nonecreate new empty sessionall()noneget all sessionshas(sessionId)key:stringverify if a session existsget(sessionId)key:stringget a session by iddelete(sessionId)key:stringdelete session by idradnom_session_id@Static methodnoneget all sessionsSessionclassNameParametersDescriptionget_session_idnoneget the id of the sessionset(key,value)key:string, value:stringadd data to the client sessionhas(key)key:stringverify if client session has the selected dataget(key)key:stringget data from client sessiondelete(key)key:stringdelete data from client sessionall()noneget client session dataEnumerationsHttpMethodsHTTP MethodsGETPOSTPUTDELETEPATCHHEADALLHttpResponsesClient sideResponse typesCodesOK200NO_CONTENT204UNAUTHORIZED401FORBIDDEN403NOT_FOUND404BAD_REQUEST400Server sideResponse typesCodesINTERNAL_SERVER_ERROR500LicenseMIT LICENSE