ASPPY is a Python-based runtime that executes Classic ASP (VBScript) pages. It provides compatibility with most VBScript built-in functions, the Classic ASP object model (Request, Response, Session, Application, Server), and various COM components commonly used in legacy ASP applications.

Platform Support

ASPPY works on:

Dependencies

The following Python libraries are required:

LibraryPurpose
Python 3.8+Runtime environment
fpdf2PDF generation (pip install fpdf2)
bcryptPassword hashing (pip install bcrypt)
PillowImage processing (pip install pillow)
pyodbcAccess/Excel/ODBC database providers (pip install pyodbc)
certifi (optional)TLS CA bundle for MSXML HTTP (pip install certifi)
zipfile (built-in)ZIP file handling

VBScript Built-in Functions

Compatibility notes for built-ins:

String Functions

FunctionDescription
Len(string)Returns the length of a string
LenB(expression)Returns the length of a string in bytes
UCase(string)Converts a string to uppercase
LCase(string)Converts a string to lowercase
Trim(string)Removes leading and trailing spaces
LTrim(string)Removes leading spaces
RTrim(string)Removes trailing spaces
StrReverse(string)Reverses a string
StrComp(string1, string2[, compare])Compares two strings
Left(string, length)Returns leftmost characters
Right(string, length)Returns rightmost characters
Mid(string, start[, length])Returns characters from a string
LeftB(string, length)Returns leftmost bytes
RightB(string, length)Returns rightmost bytes
MidB(expr, start[, length])Returns bytes from a string
InStr([start, ]string1, string2[, compare])Finds one string within another
InStrB([start, ]string1, string2)Finds one string within another (byte)
Replace(expression, find, replace[, start[, count[, compare]]])Replaces text in a string
Split(expression[, delimiter[, count[, compare]]])Splits a string into an array
Join(list[, delimiter])Joins an array into a string
Filter(inputstrings, value[, include[, compare]])Returns a filtered array
Space(number)Returns a string of spaces
String(number, character)Returns a repeating character string
Asc(string)Returns the ANSI code of the first character
AscW(string)Returns the Unicode code of the first character
AscB(string)Returns the first byte of a string
Chr(charcode)Returns the character associated with an ANSI code
ChrW(charcode)Returns the character associated with a Unicode code
ChrB(charcode)Returns a single-byte character
Hex(number)Returns the hexadecimal value
Oct(number)Returns the octal value

Array Functions

FunctionDescription
Array(arglist)Creates an array
IsArray(varname)Returns True if variable is an array
LBound(arrayname[, dimension])Returns the lowest subscript
UBound(arrayname[, dimension])Returns the highest subscript

Type Conversion Functions

FunctionDescription
CBool(expression)Converts to Boolean
CByte(expression)Converts to Byte
CCur(expression)Converts to Currency
CDbl(expression)Converts to Double
CInt(expression)Converts to Integer
CLng(expression)Converts to Long
CSng(expression)Converts to Single
CStr(expression)Converts to String
CDate(date)Converts to Date

Date/Time Functions

FunctionDescription
Now()Returns current date and time
Date()Returns current system date
Time()Returns current system time
Timer()Returns seconds since midnight
Year(date)Returns the year
Month(date)Returns the month (1-12)
Day(date)Returns the day (1-31)
Hour(time)Returns the hour (0-23)
Minute(time)Returns the minute (0-59)
Second(time)Returns the second (0-59)
DateSerial(year, month, day)Returns a date
TimeSerial(hour, minute, second)Returns a time
DateAdd(interval, number, date)Adds a time interval
DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])Returns the difference
DatePart(interval, date[, firstdayofweek[, firstweekofyear]])Returns a part of a date
Weekday(date[, firstdayofweek])Returns the weekday (1-7)
WeekdayName(weekday[, abbreviate[, firstdayofweek]])Returns the weekday name
MonthName(month[, abbreviate])Returns the month name
DateValue(string)Returns a date from a string
TimeValue(string)Returns a time from a string
CDate(string)Converts a string to a date
IsDate(expression)Returns True if expression is a date
FormatDateTime(date[, namedformat])Formats a date/time

Date Constants

ConstantValueDescription
vbSunday1Sunday
vbMonday2Monday
vbTuesday3Tuesday
vbWednesday4Wednesday
vbThursday5Thursday
vbFriday6Friday
vbSaturday7Saturday
vbUseSystemDayOfWeek0Use system day of week
vbFirstJan11First week with Jan 1
vbFirstFourDays2First week with 4 days
vbFirstFullWeek3First full week
vbGeneralDate0General date format
vbLongDate1Long date format
vbShortDate2Short date format
vbLongTime3Long time format
vbShortTime4Short time format
vbBinaryCompare0Binary comparison
vbTextCompare1Text comparison

Math Functions

FunctionDescription
Abs(number)Returns absolute value
Atn(number)Returns arctangent
Cos(number)Returns cosine
Exp(number)Returns e raised to a power
Fix(number)Returns integer portion
Int(number)Returns integer portion (floor)
Log(number)Returns natural logarithm
Rnd([number])Returns random number
Round(expression[, numdecimalplaces])Rounds a number
Sqr(number)Returns square root
Sgn(number)Returns sign of a number

Format Functions

Note: formatting functions are compatibility-focused and may differ from IIS under some locale/regional settings.

FunctionDescription
FormatNumber(expression[, numdigitsafterdecimal[, includeleadingdigit[, useparensfornegativenumbers[, groupdigits]]]])Formats a number
FormatCurrency(expression[, numdigitsafterdecimal[, includeleadingdigit[, useparensfornegativenumbers[, groupdigits]]]])Formats as currency
FormatPercent(expression[, numdigitsafterdecimal[, includeleadingdigit[, useparensfornegativenumbers[, groupdigits]]]])Formats as percentage

Information Functions

Note: type/coercion semantics generally follow VBScript, but may differ in edge cases involving Empty/Null/Nothing and host objects.

FunctionDescription
IsArray(varname)Returns True if variable is an array
IsDate(expression)Returns True if expression is a date
IsEmpty(expression)Returns True if variable is Empty
IsNull(expression)Returns True if expression is Null
IsNumeric(expression)Returns True if expression is numeric
IsObject(expression)Returns True if expression is an object
TypeName(varname)Returns the type name
VarType(varname)Returns the variant type

VarType Constants

ConstantValueDescription
vbEmpty0Empty (uninitialized)
vbNull1Null (no valid data)
vbInteger2Integer
vbLong3Long integer
vbSingle4Single-precision
vbDouble8Double-precision
vbCurrency6Currency
vbDate7Date
vbString8String
vbObject9Object
vbBoolean11Boolean
vbArray8192Array

Color Functions

FunctionDescription
RGB(red, green, blue)Returns an RGB color value

Classic ASP Objects

Server Object

Methods

MethodDescription
CreateObject(progid)Creates an instance of a COM object
HTMLEncode(string)Encodes HTML characters
URLEncode(string)URL-encodes a string
MapPath(path)Maps a virtual path to a physical path
Execute(path)Executes an ASP file
Transfer(path)Transfers execution to another ASP file
GetLastError()Returns the last error object

Properties

PropertyDescription
ScriptTimeoutGets/sets script timeout in seconds

Extension Methods (ASPPY-specific)

MethodDescription
ASPPYListAspPages()Lists all .asp pages under docroot
ASPPYRun(virtual_path)Runs another ASP page and captures output

Supported Server.CreateObject ProgIDs


Request Object

Properties

PropertyDescription
QueryStringNameValueCollection of query string parameters
FormNameValueCollection of form data parsed from POST only
CookiesNameValueCollection of cookies
ServerVariablesNameValueCollection of server variables
TotalBytesTotal bytes in request body
Method / HttpMethodHTTP method (GET, POST, PUT, DELETE, etc.)
FilesCollection of uploaded files
Request (default)Access to QueryString, Form, Cookies

Methods

MethodDescription
BinaryRead(count)Reads raw bytes from request body

HTTP methods and body parsing

Request.Files Collection

Access uploaded files from multipart form submissions.

' Iterate over all uploaded files
For Each file In Request.Files
    Response.Write(file.FileName)
    Response.Write(file.Size)
    Response.Write(file.ContentType)
    ' Save to disk
    file.SaveAs Server.MapPath("/uploads/" & file.FileName)
Next

' Access specific file
Set f = Request.Files("myfile")
If Not f Is Nothing Then
    Response.Write f.Name
    Response.Write f.FileName
    Response.Write f.Size
    Response.Write f.ContentType
End If

' Check if file exists
If Request.Files.Exists("myfile") Then
    ' File was uploaded
End If

' Get count
Response.Write Request.Files.Count

UploadedFile Properties

PropertyDescription
NameForm field name
FileNameOriginal filename
ContentTypeMIME content type
SizeFile size in bytes

UploadedFile Methods

MethodDescription
SaveAs(path)Saves the file to disk

Files Collection Methods

MethodDescription
CountNumber of uploaded files
Exists(name)Checks if file with given name exists
Item(name)Gets uploaded file by name
Keys()Returns array of field names
Items()Returns array of UploadedFile objects

Response Object

Properties

PropertyDescription
BufferEnables/disables response buffering
CookiesCollection of cookies to send
LCIDLocale identifier

Methods

MethodDescription
Write(string)Writes output to the response
BinaryWrite(data)Writes binary data
Clear()Clears the buffered output
Flush()Flushes buffered output
End()Stops script execution
AddHeader(name, value)Adds a custom header
AppendToLog(message)Appends to server log
Redirect(url)Redirects to another URL
File(path[, inline])Serves a file (inline=True for display, False for download)

Session Object

Properties

PropertyDescription
SessionIDUnique session identifier
TimeoutSession timeout in minutes
ContentsCollection of session variables
StaticObjectsCollection of session-scoped objects

Methods

MethodDescription
Abandon()Ends the session

Application Object

Properties

PropertyDescription
ContentsCollection of application variables
StaticObjectsCollection of static objects

Methods

MethodDescription
Lock()Locks application variables
Unlock()Unlocks application variables

ASPPY Extended Objects

ASPPY Object

The ASPPY object provides additional functionality beyond classic ASP.

It is available as global ASPPY in script scope.

JSON

ASPPY.JSON.Encode(value[, pretty])  ' Returns JSON string
ASPPY.JSON.Decode(json_string)      ' Returns VBScript value

Note: member access is case-insensitive in VBScript; runtime members are exposed as json, zip, image, crypto, pdf.

ZIP

ASPPY.Zip.Zip(path[, out_path])     ' Creates a ZIP file
ASPPY.Zip.Unzip(zip_path, dest_folder[, overwrite])  ' Extracts a ZIP file

Image (Pillow)

ASPPY.Image.open(path)               ' Opens an image file
ASPPY.Image.new(mode, size, color)    ' Creates a new image
ASPPY.Image.merge(mode, bands)       ' Merges image bands
ASPPY.Image.blend(img1, img2, alpha) ' Blends two images
ASPPY.Image.composite(img1, img2, mask) ' Creates composite

ASPPY.ImageDraw.Draw(img)            ' Creates a draw object
ASPPY.ImageFilter.BLUR               ' Blur filter constant
ASPPY.ImageFilter.CONTOUR            ' Contour filter
ASPPY.ImageFilter.EDGE_ENHANCE       ' Edge enhancement
ASPPY.ImageFilter.SHARPEN            ' Sharpen filter
ASPPY.ImageFilter.GaussianBlur(radius) ' Gaussian blur

ASPPY.ImageEnhance.Brightness(img)   ' Brightness enhancer
ASPPY.ImageEnhance.Contrast(img)     ' Contrast enhancer

ImageInstance Properties/Methods

Property/MethodDescription
sizeImage dimensions (width, height)
widthImage width
heightImage height
modeImage color mode
formatImage format
save(path)Saves the image
resize(size)Resizes the image
thumbnail(size)Creates thumbnail
crop(box)Crops the image
rotate(angle)Rotates the image
convert(mode)Converts color mode
split()Splits into bands
getpixel(xy)Gets pixel value
putpixel(xy, value)Sets pixel value
filter(filter_obj)Applies filter
paste(other_img, box[, mask])Pastes another image

PDF (FPDF)

Set pdf = ASPPY.Pdf.New([orientation[, unit[, format]]])

PdfDoc Methods

MethodDescription
add_page([orientation])Adds a new page
set_margins(left, top[, right])Sets page margins
set_auto_page_break(auto[, margin])Sets auto page break
set_font(family[, style[, size]])Sets the font
set_text_color(r[, g[, b]])Sets text color
set_draw_color(r[, g[, b]])Sets drawing color
set_fill_color(r[, g[, b]])Sets fill color
set_line_width(width)Sets line width
fill_page(r[, g[, b]])Fills the page with color
text(x, y, text)Writes text at position
cell(w[, h[, text[, border[, ln[, align[, fill[, link]]]]]]])Writes a cell
multi_cell(w, h, text[, border[, align[, fill]]])Writes multi-cell
set_xy(x, y)Sets current position
ln([h])Moves to next line
image(path[, x[, y[, w[, h]]]])Adds an image
output(path)Saves PDF to file

Crypto (bcrypt)

ASPPY.Crypto.Hash(password[, rounds])    ' Hashes a password (rounds 4-31, default 12)
ASPPY.Crypto.Verify(password, hashed)     ' Verifies password against hash

COM Objects

Scripting.Dictionary

Set dict = Server.CreateObject("Scripting.Dictionary")
Property/MethodDescription
CountNumber of items
CompareModeComparison mode (0=Binary, 1=Text, 2=Database)
Item(key)Gets/sets item value
KeysReturns array of keys
ItemsReturns array of items
Add(key, item)Adds a key/item pair
Exists(key)Returns True if key exists
Remove(key)Removes a key
RemoveAll()Removes all items

Scripting.FileSystemObject

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Property/MethodDescription
BuildPath(path, name)Builds a path
CreateTextFile(filename[, overwrite[, unicode]])Creates text file
OpenTextFile(filename[, iomode[, create[, format]]])Opens text file
GetFile(filepath)Gets File object
GetFolder(folderpath)Gets Folder object
GetDrive(drivespec)Gets Drive object
DriveExists(drivespec)Checks if drive exists
FileExists(filepath)Checks if file exists
FolderExists(folderpath)Checks if folder exists

File Object

Property/MethodDescription
PathFull path
NameFile name
SizeFile size
TypeFile type
DateCreatedCreation date
DateLastAccessedLast access date
DateLastModifiedLast modified date
DriveDrive letter
ParentFolderParent folder
ShortName8.3 name
ShortPath8.3 path
AttributesFile attributes
Copy(destination[, overwrite])Copies file
Move(destination)Moves file
Delete([force])Deletes file
OpenAsTextStream([iomode[, format]])Opens as text stream

Folder Object

Property/MethodDescription
PathFull path
NameFolder name
SizeTotal size of folder
DateCreatedCreation date
DateLastAccessedLast access date
DateLastModifiedLast modified date
DriveDrive letter
IsRootFolderTrue if root
FilesFiles collection
SubFoldersSubfolders collection
AttributesFolder attributes
Copy(destination[, overwrite])Copies folder
Move(destination)Moves folder
Delete([force])Deletes folder

TextStream Object

Property/MethodDescription
AtEndOfStreamTrue at end of file
Read(n)Reads n characters
ReadLine()Reads a line
ReadAll()Reads entire file
Write(string)Writes string
WriteLine([string])Writes line
WriteBlankLines(n)Writes blank lines
Close()Closes the stream
Skip(n)Skips n characters
SkipLine()Skips a line

VBScript.RegExp

Set regex = Server.CreateObject("VBScript.RegExp")
Property/MethodDescription
PatternRegular expression pattern
IgnoreCaseCase-insensitive matching
GlobalMatch all occurrences
MultiLineMulti-line matching
Test(string)Tests for a match
Replace(string, replace_with)Replaces matches
Execute(string)Returns match collection

ADODB.Connection

Set conn = Server.CreateObject("ADODB.Connection")
Property/MethodDescription
ConnectionStringConnection string
StateConnection state
CommandTimeoutCommand timeout
CursorLocationCursor location
Open([connection_string])Opens connection
Close()Closes connection
Execute(sql[, records_affected[, options]])Executes SQL
BeginTrans()Begins transaction
CommitTrans()Commits transaction
RollbackTrans()Rolls back transaction

Connection string notes:

ADODB.Recordset

Set rs = Server.CreateObject("ADODB.Recordset")
Property/MethodDescription
StateRecordset state
EOFEnd of file
BOFBeginning of file
RecordCountNumber of records
FieldsFields collection
Open([source[, active_conn[, cursor_type[, lock_type[, options]]]]])Opens recordset
Close()Closes recordset
MoveFirst()Moves to first record
MoveLast()Moves to last record
MoveNext()Moves to next record
MovePrevious()Moves to previous record
Move(n)Moves n records
AddNew()Starts insert mode for a new record
Update()Commits pending field changes
Delete()Deletes current record
ResyncResyncs with database

ADODB.Command

Set cmd = Server.CreateObject("ADODB.Command")
Property/MethodDescription
ActiveConnectionConnection used for execution
CommandTextSQL command text
CommandTypeCommand type (text)
ParametersParameters collection
CreateParameter(...)Creates a parameter object
Execute(...)Executes command and returns a recordset

ADODB.Parameter / Parameters

Property/MethodDescription
NameParameter name
TypeADO type constant
DirectionDirection (adParamInput, etc.)
SizeDeclared size
ValueParameter value
Parameters.Append(param)Adds parameter
Parameters.Item(name_or_index)Gets parameter
Parameters.CountNumber of parameters

ADODB.Stream

Set stream = Server.CreateObject("ADODB.Stream")
Property/MethodDescription
TypeStream type (1=Binary, 2=Text)
CharsetCharacter set
PositionCurrent position
SizeStream size
EOSEnd of stream
StateStream state
LineSeparatorLine separator
ModeOpen mode
Open()Opens stream
Close()Closes stream
LoadFromFile(filename)Loads from file
SaveToFile(filename[, options])Saves to file
Read([count])Reads bytes
ReadText([count])Reads text
Write(data)Writes bytes
WriteText(string)Writes text
CopyTo(dest_stream[, count])Copies to another stream
SetEOS()Sets EOS
SkipLine()Skips line
Flush()Flushes buffer

MSXML2 Objects

ServerXMLHTTP

Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
Property/MethodDescription
ReadyStateRequest state
StatusHTTP status code
StatusTextHTTP status text
ResponseTextResponse as text
ResponseXMLResponse as XML DOM
ResponseBodyResponse as binary
OptionMSXML option
Open(method, url[, async[, user[, password]]])Opens request
SetRequestHeader(header, value)Sets request header
Send([body])Sends request
WaitForResponse([timeout])Waits for response
Abort()Aborts request

XMLHTTP

Set http = Server.CreateObject("MSXML2.XMLHTTP")

Same interface as ServerXMLHTTP.

DOMDocument

Set xml = Server.CreateObject("MSXML2.DOMDocument")
Property/MethodDescription
asyncAsync loading
readyStateDocument state
xmlXML content
textText content
load(url)Loads from URL
loadXML(xml_string)Loads from string
save(destination)Saves document
selectNodes(xpath)Selects nodes
selectSingleNode(xpath)Selects single node
getElementsByTagName(tagname)Gets elements

CDO.Message

Set msg = Server.CreateObject("CDO.Message")
Property/MethodDescription
FromSender address
ToRecipient address(es)
CCCC recipients
BCCBCC recipients
SubjectMessage subject
HTMLBodyHTML body
TextBodyPlain text body
BodyPartBody part object
ConfigurationConfiguration object
DisableSendIf True, Send() is no-op success
AddAttachment(url)Adds attachment
Send()Sends the message

ASPPY.POP3

Set pop = Server.CreateObject("ASPPY.POP3")
MethodDescription
Connect/Open(host[, port[, use_ssl[, timeout]]])Connects to POP3 server
Login(user, pass)Authenticates
Stat()Returns message count and mailbox size
List()Returns message listing
UIDL([msg_num])UID listing or UID for one message
Retr/GetMessage(msg_num)Fetches a message object
Delete/Dele(msg_num)Marks message for deletion
DeleteAll()Marks all for deletion
Quit/Close()Closes connection

ASPPY.IMAP

Set imap = Server.CreateObject("ASPPY.IMAP")
MethodDescription
Connect/Open(host[, port[, use_ssl[, timeout]]])Connects to IMAP server
Login(user, pass)Authenticates
Select([folder[, readonly]])Selects mailbox
Search([criteria])Finds messages by sequence number
SearchUID([criteria])Finds messages by UID
Fetch/GetMessage(msg_num)Fetches message by sequence number
GetMessageByUID(uid)Fetches message by UID
Delete/Dele(msg_num)Marks message deleted
DeleteAll()Marks all selected messages deleted
Expunge()Permanently removes deleted messages
Logout/Close()Closes connection

Runtime Environment Variables

VariableDescription
ASP_PY_LOGEnables request log output from built-in server
ASP_PY_TRACE_REQUESTEnables verbose request/body trace logging
ASP_PY_REQ_MEM_MAXMax in-memory request body bytes before temp-file buffering
ASP_PY_ADO_ROOTSandbox root for ADODB.Stream filesystem operations
ASP_PY_FSO_ROOTSandbox root for Scripting.FileSystemObject
ASP_PY_HTTP_MAX_BYTESMax response bytes for MSXML HTTP requests
ASP_PY_HTTP_ALLOW_HOSTSComma-separated HTTP host allowlist for MSXML
ASP_PY_ALLOW_LOCALHOSTAllows MSXML HTTP access to localhost
ASP_PY_ALLOW_PRIVATE_NETSAllows MSXML HTTP access to private subnets
ASP_PY_XML_ALLOW_LOCALAllows DOMDocument local file loading
ASP_PY_CDO_DISABLE_SENDDisables SMTP send in CDO.Message
ASP_PY_CDO_ALLOW_OUTSIDE_DOCROOTAllows CDO attachments outside docroot

VBScript Compatibility Notes

Compatibility Matrix

SubsystemLevelNotes
Core VBScript built-insNearBroad coverage for common Classic ASP apps; edge coercion/locale behaviors can differ
Date/time and numeric formattingPartialCompatibility-oriented; locale-specific IIS parity not guaranteed
Request/Response/Server/Application/SessionNearClassic object model implemented; some operational semantics differ from IIS hosting internals
VBScript.RegExpNearCommon API and VB-style replacement tokens supported
Scripting.DictionaryNearCore collection behavior supported; COM-level quirks may differ
Scripting.FileSystemObject / ADODB.StreamPartialSupported in sandboxed model (docroot/root-constrained)
ADODB.Connection/Recordset/CommandPartialProvider support is runtime-dependent; ADO surface is compatibility-oriented
Database providersPartialSQLite, Access, Excel(read-only), generic ODBC, PostgreSQL via ODBC
MSXML HTTP/DOM shimsPartialSecurity-guarded and stdlib-focused; not full MSXML COM parity
CDO.MessagePartialPractical SMTP/pickup subset; not complete CDOSYS feature parity
POP3/IMAP shimsPartialLegacy-friendly subset for mailbox workflows

Global.asa Support

ASPPY supports the Global.asa file with the following events:

Example Global.asa:

<script language="vbscript" runat="server">
Sub Application_OnStart
    Application("StartTime") = Now()
End Sub

Sub Session_OnStart
    Session("UserID") = ""
End Sub
</script>

Running ASPPY

Start the built-in server:

python -m ASPPY.server [host] [port] [docroot]

Example:

python -m ASPPY.server 0.0.0.0 8080 www

The server will serve both static files and .asp pages from the specified document root.