- Global variables and functions
- No need to recompile for each edit (but supported)
- Automatic library integration, no Package Manager
- Show compiler errors in browser
- MySQL
SwiftyWeb includes a Swift helper for CGI.
You can use it like this:
// GET
"h1".htm() {
print("GET Parameters")
}
"ul".htm() {
for (key, value) in GET {
"li".htm() {
print(key+":"+value)
}
}
}
// POST
"h1".htm() {
print("POST Parameters")
}
"ul".htm() {
for (key, value) in POST {
"li".htm() {
print(key+":"+value)
}
}
}
Init a project, install via the package manager, compile and move?
NO.
With SwiftyWeb, you can simply write your code and open the browser.
Install typing this in a shell:
curl https://raw.githubusercontent.com/ColdGrub1384/SwiftyWeb/master/install 2>/dev/null | sudo bash
Or, inside this repo, run:
./install nodownload
Now, you can write Swift CGIs putting this in the top or your file:
#!/usr/bin/swiftw
// Your code here
(Don't forget to chmod +x your file)
You can also include other files:
#!/usr/bin/swiftw AnotherFile.swift
// Your code here
Loading CGIs with '#!/usr/bin/swiftw' is very slow, you can compile files manually typing:
swiftw -o PATH_TO_NEW_EXECUTABLE FILES TO COMPILE
A file will be created and you can put it in your CGI's folder.
In Mac, you can also build the framework opening SwiftyWeb.xcodeproj
and include framework in your command line project. Don't forget to print "Content-Type: text/html\nContent:\n"
!
If you want to contribute to the documentation, don't edit the docs
directory, but just document the code, the page will be generated by me with Jazzy, or if you want, generate it yourself.
- Install Jazzy:
[sudo] gem install jazzy
-
And run the
build-documentation.sh
script inside this repo. -
Increment
version
field indocs/docsets/Pisth.xml
.
My web page is coded with SwiftyWeb: colg.ddns.net