Jump to content
Sign in to follow this  
Dhilip89

NetFlare Web Server (Version 0.3)

Recommended Posts

Updated to version 0.2


[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Share this post


Link to post
Share on other sites

Very nice. Just had a quick browse over the code and it was very interesting to read. At first I thought I was stumped at how it worked as the code is spread out, but eventually I found the parsing function.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

Great work. How do you retrieve GET and POST data into the autoit-code?

 

Thanks, starting from version 0.3 both GET and POST data is supported.


[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Share this post


Link to post
Share on other sites

Very nice. Just had a quick browse over the code and it was very interesting to read. At first I thought I was stumped at how it worked as the code is spread out, but eventually I found the parsing function.

 

Thank you, it was my random idea then I made this to practice my rusted AutoIt coding skill  :oops:


[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Share this post


Link to post
Share on other sites

Check out version 0.3

Added stress test animation (in GIF)

Edited by Dhilip89

[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Share this post


Link to post
Share on other sites

Hi. Thank you very much for such a great UDF. For me it is magic :)

I wonder If I set the port to say

HttpServer_SetPort(8080)

Then I have to access to my local website from http://127.0.0.1:8080 address. The same would happen with external ips http.xx.xx.xx.xx:8080

How should I configure the port so that I could have a direct access to http://127.0.0.1?

Great thanx in advance!

Share this post


Link to post
Share on other sites

 

How should I configure the port so that I could have a direct access to http://127.0.0.1?

Great thanx in advance!

Are you asking if you could connect to 127.0.0.1 from the internet? If you are, the answer is, you can't it is impossible. 127.0.0.1 is a local loopback address only.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

BrewManNH

 I know that 127.0.0.1 is a localhost. The thing is- when I am trying to open the website localy - shows only blank page. If I set the port to 8080 then I get the access only if I navigate it this way: 127.0.0.1:8080 - then the web page opens normally. The same happens when I navigate it somewhere from internet. Say I would have an Ip something like 123.123.123.123 Then when I navigate it directly 123.123.123.123- nothing happens. But when I navigate it 123.123.123.123:8080 The website opens ok from Internet.

 

Share this post


Link to post
Share on other sites

80 is the default HTTP port, so I would guess you'd set it to that instead of 8080.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Dear coders

I  really like this UDF, because it is opening really huge possibilities: We are not dependant on php and other "officialy" accepted scripts and languages for web.

Important thing, what about security? I mean, is it secure for injections and other things, which hackers use against websites?

Great thanx in advance

Share this post


Link to post
Share on other sites

Dear coders

I  really like this UDF, because it is opening really huge possibilities: We are not dependant on php and other "officialy" accepted scripts and languages for web.

Important thing, what about security? I mean, is it secure for injections and other things, which hackers use against websites?

Great thanx in advance

I hope the IP change I suggested worked for your setup

As far as hackers ... I don't know how to say it. This script will not give you SSL, so, all you have is plain text , anyone logging packets can see the conversation between server and client. As far as SQL injections, that has to do with SQL

I run a web server written in autoit that I use as a log dumper of sorts. My programs send an encrypted string and I process that. If I was to write it now, I'd use an Apache server and PHP.

Play around, hack yourself your script and have fun learning everything you can about anything that can be done in that arena. I know of no other way.

exploits_of_a_mom.png

 

Edited by argumentum
added the pic.

Share this post


Link to post
Share on other sites

Argumentum, thank you very much for your comment. The picture is quite descriptive :)

@IP 0.0.0.0 didnt work for me at least on my pc, but I am going to test in other pc to see the final result

@hacking etc. I would like to clearfy my question: Is the server secure for calculations which autoit is doing on the server? For example from the client side I send some post request  to server. The server receives it and then it makes some calculations on the side of autoit $a+$b=$c and many other autoit functions and then it sends to client ok, $c=2345. The question is: Can client interfere into those calculations which autoit is doing on the server. For example by navigating to website using some code like "www.website.com: msgbox (0, "", "hacked")" (I am using a pseudocode of course, but I think you get the idea)?

Great thanx in advance!

Share this post


Link to post
Share on other sites

Argumentum, thank you very much for your comment. The picture is quite descriptive :)

@IP 0.0.0.0 didnt work for me at least on my pc, but I am going to test in other pc to see the final result

@hacking etc. I would like to clearfy my question: Is the server secure for calculations which autoit is doing on the server? For example from the client side I send some post request  to server. The server receives it and then it makes some calculations on the side of autoit $a+$b=$c and many other autoit functions and then it sends to client ok, $c=2345. The question is: Can client interfere into those calculations which autoit is doing on the server. For example by navigating to website using some code like "www.website.com: msgbox (0, "", "hacked")" (I am using a pseudocode of course, but I think you get the idea)?

Great thanx in advance!

the answer to A+B=C question is no. No one can run stuff on your PC that you don't code for, ..then again if you use something like $c = execute($a+$b) then you are coding with the possibility of malicious code run, now if you do like $c = Int($a) + Int($b) is known that can not bring harm. So getting hacked is relative to how you code and nothing more.

Share this post


Link to post
Share on other sites

...From a quick glance to the source, it seems that the autoit code embedded in the web page is executed on the server one line at a time. See the Aup_Execute() function within the Lib\WebAupProcessor.au3 script. Don't know if this is a good way to embed code within the source web page . Maybe it would be better to be able to execute entire snippets instead of single lines at a time. Executing only single lines of code will limit your programming possibilities.
You will be bound not to use constructs like "for ... next" for example, and other similar restrictions.
Have also a look to this other embrional example on how to embed AutoIt code in web pages and execute it on the server using this other Web Server

Edited by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

tell you what. Try some this. a php file 

<?php
    foreach($_SERVER as $key => $value) {
    //putenv('php_SERVER__'.$key.'='. bin2hex($value) );
        if(strpos($key, 'HTTP') === 0) {
            putenv('php_SERVER__'.$key.'='. bin2hex($value) ); // or just these
        }
    }
    foreach($_POST as $key => $value) {
        putenv('php_POST__'.$key.'='. bin2hex($value) );
    }
    foreach($_GET as $key => $value) {
        putenv('php_GET__'.$key.'='. bin2hex($value) );
    }
    foreach($_COOKIE as $key => $value) {
        putenv('php_COOKIE__'.$key.'='. bin2hex($value) );
    }
    $time_start = microtime(true);
    passthru('C:\xampp\cgi-bin\test1.exe');
    $time_end = microtime(true);
    print "<b>PHP Execution Time:</b> ". number_format(($time_end - $time_start) * 1000) ." mSec.<br>\r\n" ;
?>

and a CUI compiled AutoIt, like:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <WinAPI.au3>
#include <WinAPIMisc.au3>

Local $t = TimerInit()

ConsoleWrite("<b>AutoIt Macros:</b><br>" & @CRLF)
fShowAvailableMacros()

ConsoleWrite("<br><b>Environment Strings:</b><br>" & @CRLF)
_WinApi_GetEnvironmentStringsA()

ConsoleWrite('<br>AutoIt Execution Time: ' & Round(TimerDiff($t)) & ' mSec.<br>' & @CRLF)

Func fShowAvailableMacros()
    Local $aMacros[111 - 6] = [110 - 6, _
            "@AppDataCommonDir", _
            "@AppDataDir", _
            "@AutoItExe", _
            "@AutoItPID", _
            "@AutoItVersion", _
            "@AutoItX64", _
            "@COM_EventObj", _
            "@CommonFilesDir", _
            "@Compiled", _
            "@ComputerName", _
            "@ComSpec", _
            "@CPUArch", _
            "@DesktopCommonDir", _
            "@DesktopDepth", _
            "@DesktopDir", _
            "@DesktopHeight", _
            "@DesktopRefresh", _
            "@DesktopWidth", _
            "@DocumentsCommonDir", _
            "@error", _
            "@exitCode", _
            "@exitMethod", _
            "@extended", _
            "@FavoritesCommonDir", _
            "@FavoritesDir", _
            "@GUI_CtrlHandle", _
            "@GUI_CtrlId", _
            "@GUI_DragFile", _
            "@GUI_DragId", _
            "@GUI_DropId", _
            "@GUI_WinHandle", _
            "@HomeDrive", _
            "@HomePath", _
            "@HomeDrive.", _
            "@HomeShare", _
            "@HotKeyPressed", _
            "@HOUR", _
            "@IPAddress1", _
            "@IPAddress2", _
            "@IPAddress3", _
            "@IPAddress4", _
            "@KBLayout", _
            "@LocalAppDataDir", _
            "@LogonDNSDomain", _
            "@LogonDomain", _
            "@LogonServer", _
            "@MDAY", _
            "@MIN", _
            "@MON", _
            "@MSEC", _
            "@MUILang", _
            "@MyDocumentsDir", _
            "@NumParams", _
            "@OSArch", _
            "@OSBuild", _
            "@OSLang", _
            "@OSServicePack", _
            "@OSType", _
            "@OSVersion", _
            "@ProgramFilesDir", _
            "@ProgramsCommonDir", _
            "@ProgramsDir", _
            "@ScriptDir", _
            "@ScriptFullPath", _
            "@ScriptDir", _
            "@ScriptName", _
            "@ScriptLineNumber", _
            "@ScriptName", _
            "@SEC", _
            "@StartMenuCommonDir", _
            "@StartMenuDir", _
            "@StartupCommonDir", _
            "@StartupDir", _
            "@SW_DISABLE", _
            "@SW_ENABLE", _
            "@SW_HIDE", _
            "@SW_LOCK", _
            "@SW_MAXIMIZE", _
            "@SW_MINIMIZE", _
            "@SW_RESTORE", _
            "@SW_SHOW", _
            "@SW_SHOWDEFAULT", _
            "@SW_SHOWMAXIMIZED", _
            "@SW_SHOWMINIMIZED", _
            "@SW_SHOWMINNOACTIVE", _
            "@SW_SHOWMINIMIZED,", _
            "@SW_SHOWNA", _
            "@SW_SHOW,", _
            "@SW_SHOWNOACTIVATE", _
            "@SW_SHOWNORMAL,", _
            "@SW_SHOWNORMAL", _
            "@SW_UNLOCK", _
            "@SystemDir", _
            "@TempDir", _
            "@TRAY_ID", _
            "@TrayIconFlashing", _
            "@TrayIconVisible", _
            "@UserName", _
            "@UserProfileDir", _
            "@WDAY", _
            "@WindowsDir", _
            "@WorkingDir", _
            "@YDAY", _
            "@YEAR"]

    For $n = 1 To 5 ; $aMacros[0]
        ConsoleWrite($aMacros[$n] & '&nbsp;=&nbsp;&gt;' & Execute($aMacros[$n]) & '&lt;<BR>' & @CRLF)
    Next
    ConsoleWrite('.. etc.<BR>' & @CRLF)
EndFunc   ;==>fShowAvailableMacros

Func _WinApi_GetEnvironmentStringsA() ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms683187(v=vs.85).aspx
    ; https://www.autoitscript.com/forum/topic/178400-windows-environment-variables-viewer/
    Local $pEnvBlock, $iPtrStringLen, $tEnvString, $aSplit, $aRet, $sEnvString, $aEnvString[0][2]
    $aRet = DllCall('kernel32.dll', 'ptr', 'GetEnvironmentStringsA') ; GetEnvironmentStringsA returns OEM characters.
    If @error Then Return SetError(@error, @extended, '')
    $pEnvBlock = $aRet[0] ; pointer to a block of memory that contains the environment variables.
    If Not IsPtr($pEnvBlock) Then Return SetError(-1, 0, '')
    While 1
        $iPtrStringLen = _WinAPI_StringLenA($pEnvBlock)
        If $iPtrStringLen > 0 Then
            $tEnvString = DllStructCreate('char[' & $iPtrStringLen + 1 & ']', $pEnvBlock)
            $sEnvString = _WinAPI_OemToChar(DllStructGetData($tEnvString, 1)) ; Convert Oem to Ansi.
            If StringLeft($sEnvString, 1) <> '=' Then
                $aSplit = StringSplit($sEnvString, '=', 1 + 2)
                If Not @error Then
                    ReDim $aEnvString[UBound($aEnvString) + 1][2]
                    $aEnvString[UBound($aEnvString) - 1][0] = $aSplit[0] ; name
                    $aEnvString[UBound($aEnvString) - 1][1] = $aSplit[1] ; value
                    If StringInStr( $aSplit[0] , "php_") == 1 Then
                        ConsoleWrite($aSplit[0] & '&nbsp;=&nbsp;&gt;' & BinaryToString('0x'&$aSplit[1]) & '&lt;<BR>' & @CRLF) ; <----- added just to show the PHP thing
                    Else
                        ;ConsoleWrite($aSplit[0] & ' = ' & $aSplit[1] & '<BR>' & @CRLF) ; <----- added just to show the PHP thing
                    EndIf
                EndIf
            EndIf
            $pEnvBlock += $iPtrStringLen + 1
        Else
            _WinApi_FreeEnvironmentStringsA($pEnvBlock) ; Free memory block.
            $tEnvString = 0
            Return SetError(0, 0, $aEnvString)
        EndIf
    WEnd
EndFunc   ;==>_WinApi_GetEnvironmentStringsA

Func _WinApi_FreeEnvironmentStringsA($pEnv) ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms683151(v=vs.85).aspx
    Local $aRet = DllCall('kernel32.dll', 'int', 'FreeEnvironmentStringsA', 'ptr', $pEnv)
    If Not @error And $aRet[1] <> 0 Then Return SetError(0, @extended, $aRet[1])
    Return SetError(@error, 0, 0)
EndFunc   ;==>_WinApi_FreeEnvironmentStringsA

and see if that's good for you. It worked just fine on my PC and I can have SSL from whatever Apache uses for SSL

Edit: tweaked the code to have the server pass info. that you'll use in your script via environment variables, so you can do:
http://localhost/test1.php?val1=this1&val2=this Other Thing
as GET or make a form and use POST
 

Edited by argumentum
tweaked the code

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Jahar
      Hi,
      I am new to Autoit, Kindly guide me. I wanted to send a message with HTTP/GET to the URL https://ghsff.it/. How to do so?
    • By tarretarretarre
      About AutoIt-API-WS
      AutoIt-API-WS is a light weight web server with expressive syntax, with the sole purpose of wrapping your existing AutoIt app with little to no effort.
      With AutoIt-API-WS you can send and receive data between any application or framework, as long they can handle HTTP requests, which is an industry standard today.
      Like my other communcations UDF AutoIt-Socket-IO AutoIt-API-WS is heavily inspired from the big boys, but this time its Laravel and Ruby on Rails.
      Features Highlights
      No external or internal dependencies required RESTful mindset when designed Expressive syntax Small codebase Heavy use of Michelsofts Dictionary object Limitations
      Not complient with any RFC, so something important could be missing. Time will tell! One persons slow loris attack will kill the process forever. Example of implemetnation (With screenshots)
      This is a basic cRud operation with the RESTful mindset in use.
      #include "API.au3" #include <Array.au3> _API_MGR_SetName("My APP DB adapter") _API_MGR_SetVer("1.0 BETA") _API_MGR_SetDescription("This adapter allows you to get this n that") _API_MGR_Init(3000) _API_MGR_ROUTER_GET('/users', CB_GetUsers, 'string sortBy', 'Get all users, sortBy can be either asc or desc. asc is default') _API_MGR_ROUTER_GET('/users/{id}', CB_GetUsersById, 'int id*', 'Get user by id') While _API_MGR_ROUTER_HANDLE() WEnd Func DB_GetUsers() Local $userA = ObjCreate("Scripting.Dictionary") Local $userB = ObjCreate("Scripting.Dictionary") $userA.add('id', 1) $userA.add('name', 'TarreTarreTarre') $userA.add('age', 27) $userB.add('id', 2) $userB.add('name', @UserName) $userB.add('age', 22) Local $aRet = [$userA, $userB] Return $aRet EndFunc Func CB_GetUsers(Const $oRequest) Local $aUsers = DB_GetUsers() If $oRequest.exists('sortBy') Then Switch $oRequest.item('sortBy') Case Default Case 'asc' Case 'desc' _ArrayReverse($aUsers) EndSwitch EndIf Return $aUsers EndFunc Func CB_GetUsersById(Const $oRequest) Local Const $aUsers = DB_GetUsers() Local $foundUser = Null For $i = 0 To UBound($aUsers) -1 Local $curUser = $aUsers[$i] If $curUser.item('id') == $oRequest.item('#id') Then $foundUser = $curUser ExitLoop EndIf Next If Not IsObj($foundUser) Then Return _API_RES_NotFound(StringFormat("Could not find user with ID %d", $oRequest.item('#id'))) EndIf return $foundUser EndFunc When you visit http://localhost:3000 you are greeted with this pleasent view that will show you all your registred routes and some extra info you have provided.

      When you visit http://localhost:3000/users the UDF will return the array of objects as Json
       
      And here is an example of http://localhost:3000/users/1

       
      More examples can be found here
       
       
      Autoit-API-WS-1.0.0-beta.zip (OLD!)
      Autoit-API-WS-1.0.1-beta.zip (NEWEST 2020-06-29)
    • By nacerbaaziz
      goodmorning autoit team
      today am comming with some winhttp problems, i hope that you can help me to solve them.
      the first problem
      is when opening a request
      my forums api allow me to delete any post using the api key
      all functions work, i mean post / get
      but when i tried to use the delete verb it's gave me an html 404 error
      here is what am tried
      #include "WinHttp.au3" ; Open needed handles Global $hOpen = _WinHttpOpen() Global $hConnect = _WinHttpConnect($hOpen, "xxxxxxxx.com") ; Specify the reguest: Global $hRequest = _WinHttpOpenRequest($hConnect, "Delete", "/vb/Api/posts/10447/?hard_delete=true", default, default) _WinHttpAddRequestHeaders($hRequest, "XF-Api-Key:xxxxx") _WinHttpAddRequestHeaders($hRequest, "XF-Api-User:xxxxx") ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) Global $sHeader = 0, $sReturned = 0 ; If there is data available... If _WinHttpQueryDataAvailable($hRequest) Then $sHeader = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_DISPOSITION) ;Or maybe: ; $sHeader = _WinHttpQueryHeaders($hRequest, BitOR($WINHTTP_QUERY_RAW_HEADERS_CRLF, $WINHTTP_QUERY_CUSTOM), "Content-Disposition") Do $sReturned &= _WinHttpReadData($hRequest) Until @error msgBox(64, "", $sReturned) endIf ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)  
      and here is the error message
      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don't have permission to access /vb/Api/posts/10447/ on this server.<br /> </p> </body></html>  
      i hope you can help me 
      thanks in advance
    • By TheXman
      Purpose (from Microsoft's website)
      The HTTP Server API enables applications to communicate over HTTP without using Microsoft Internet Information Server (IIS). Applications can register to receive HTTP requests for particular URLs, receive HTTP requests, and send HTTP responses. The HTTP Server API includes SSL support so that applications can exchange data over secure HTTP connections without IIS.
      Description
      There have been several times in the past that I wanted to either retrieve information from one of my PCs or execute commands on one of my PCs, whether it was from across the world or sitting on my couch.  Since AutoIt is one of my favorite tools for automating just about anything on my PC, I looked for ways to make to make it happen.  Setting up a full blown IIS server seemed like overkill so I looked for lighter weight solutions.  I though about creating my own AutoIt UDP or TCP server but that just wasn't robust enough,  Then I found Microsoft's HTTP Server API and it looked very promising.  After doing a little research into the APIs, I found that it was flexible & robust enough to handle just about any of the tasks that I required now and in the future.  So a while back I decided to wrap the API functionality that I needed into an AutoIt UDF file to allow me to easily create the functionality I needed at the time.  It has come in very handy over the years.  Of course it wasn't all wrapped up with a nice little bow like it is now.  That only happened when I decided to share it with anyone else who could use it or learn from it.
      The example file that I included is a very granular example of the steps required to get a lightweight HTTP Server up and listening for GET requests.  The UDF is a wrapper for the Microsoft APIs.  That means to do anything over and above what I show in the example, one would probably have to have at least a general knowledge of APIs or the ability to figure out which APIs/functions to use, what structures and data is needed to be passed to them, and in what order.  However, the UDF gives a very solid foundation on which to build upon.  Of course, if anyone has questions about the UDF or how to implement any particular functionality, I would probably help to the extent that I could or point you in the right direction so that you can figure out how to implement your own solution.
      The APIs included in the UDF are the ones that I needed in the past to do what I needed to do.  If any additional APIs need to be added to the UDF file, please make those suggestions in the related forum topic.
      Being that this is basically an AutoIt wrapper for the Microsoft API functions, there's no need to create AutoIt-specific documentation.  All of the UDF functions, structures, constants, and enumerations are named after their Microsoft API counterparts.  Therefore, you can refer to Microsoft's extensive documentation of their HTTP Server API.  As stated earlier, if there is one or more APIs that you find yourself needing for your particular solution, please suggest it in the related Example Scripts forum topic.
      Related Links
      Microsoft HTTP Server API - Start Page
      Microsoft HTTP Server API - API v2 Reference
      Microsoft HTTP Server API - Programming Model
×
×
  • Create New...