This means if you want to access a page on your site, the URL will be of the form: You can change this by editing prefs.json in the prefs folder. The first time you run PagePark it will open on port 1339. Here's the source code for the script in the demo below. We run the script, and the return value is returned to the caller, with type of text/html. The text in the file is passed through a Markdown processor and that text is returned. The outline is rendered as an expandable outline, the type returned is text/html. The contents of the file is returned with type image/png. The text in the file is returned, the type is application/json. The text in the file is returned, the type is text/xml. The text in the file is returned, the type is text/plain. The extension of a file determines how PagePark serves it. There are three special endpoints on all domains: /version, /now and /status that return the version of PagePark that's running, the time on the server and the stats and prefs. If you want to run PagePark from a folder different from the one that contains the app, set the pageparkFolderPath environment variable to point to that folder. So the index file can be HTML, Markdown or a script, or any other type PagePark can serve. If a request comes in for a folder, we scan the folder for a file whose name begins with index and serve the first one we find. You can edit this file to provide a common template for all your Markdown documents. MdTemplate.txt is the template we use to serve Markdown text. Stats.json contains information generated by the server including the number of times the server has started, how many hits it's received (all time and today), and hits by domain. These include the port that the server runs on and the name of the index file (see below). The prefs folder contains a file of settings you can change, prefs.json. Here's an example of a script that I have running on one of my servers. js are interpreted as scripts only if the associated config setting is turned on. md are passed through the built-in Markdown processor. Serves all major media types including audio and video. The contents within the folder are what we serve. Each folder's name is the name of a domain. PagePark will automatically create a prefs sub-folder and a domains sub-folder.Īdd your web content under domains. Here's a screen shot of an example PagePark domains folder. If this worked, congratulations - you just installed a web server. You should see the text you entered in the previous step. In a browser, running on the same machine, enter localhost:1339. Using a text editor add a file to the localhost folder called index.md. To run the server, enter node pagepark.js.Ĭreate a sub-folder of the domains folder called localhost. Install Node.js if you don't already have it running, including the NPM package manager.ĭownload the PagePark folder from the GitHub repository. How to get started quickly with PagePark. And it's easy to hack the code if you want to. A real one you can use to host your sites. It's 90 percent of what all web servers do, so if you learn how to run PagePark, you're learning how to run a web server. And of course HTML, text files, images, movies, etc. It can serve Markdown docs, or optionally run JavaScript code. The content for that domain is in the folder. It's written in JavaScript and runs in Node.js.Įach domain is in its own folder. Think of it as a nice park where you keep your pages. Then I kept going and added all the features I want to help me manage my own websites, far beyond just parking them. I wrote this simple HTTP server to park domains I've bought but not yet used.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |