Simplest way to host html [duplicate] - html

This question already has answers here:
Best lightweight web server (only static content) for Windows [closed]
(8 answers)
Closed 8 years ago.
What is the simplest way to host an HTML page over LAN?
I literally just need to have like 5 lines of HTML, so I don't want to download and setup an Apache server. I just want to know the fastest/simplest way to do this on Windows, or I can also use one of my Linux virtual machines if it's faster.

Use netcat, or nc:
:top
nc -l -p 80 -q 1 < index.html
goto top
It's a simple binary without any installation. It doesn't do CGI or PHP or anything, but it can sure dish up 5 lines of HTML.
Actually, if you use the "k" (keep-alive) option you can remove the loop, and make it simpler:
nc -kl 80 < index.html

Since you need a web server for testing and no heavy concurrent use is expected, I'll just keep it simple.
Please note that both solutions are very simple but not very secure, use them for development purposes but don't rely on neither of them for anything barely similar to a stable (people would say "production") server.
Navigate to the directory where your HTML file is located using cmd.exe, then issue:
Using Python
python -m SimpleHTTPServer
A HTTP server will be started on port 8000. Should you need a different port, just specify it:
python -m SimpleHTTPServer 8080
SimpleHTTPServer is part of the "batteries included": you will not need to install any extra package, apart from the Python interpreter, of course.
Python comes already installed on most Linux distributions, so switching to Linux might be simpler than install Python on Windows, although that boils down to downloading and running an installer.
Using PHP 5.4 or above
php -S 0.0.0.0:8080
This will also process PHP scripts, but HTML resources will be served fine.

http://www.lighttpd.net/ is pretty light weight and easy to get running.

I recently used mongoose for a similar purpose. It supports Windows. From the homepage:
Mongoose executable does not depend on any external library or
configuration. If it is copied to any directory and executed, it
starts to serve that directory on port 8080. If some additional config
is required - for example, different listening port or IP-based access
control, then a mongoose.conf file with respective options (see
example) can be created in the same directory where executable lives.
This makes Mongoose perfect for all sorts of demos, quick tests, file
sharing, and Web programming.
Download the windows exe (no need to install) from here , save it on the folder where your html file is and execute it. Check the image below to know how to start the server:
After selecting Start Browser on Port 8080 your browser will open automatically displaying the contents of the folder.

Related

How deploy .htm extension on a server?

I want to learn AngularJs from http://www.tutorialspoint.com/angularjs
but an example must be deployed a server. I don't know anything about it.
Please give me some hint about deploy .htm extension file to a server.
Example url is following;
http://www.tutorialspoint.com/angularjs/angularjs_includes.htm
I believe that they just mean placing the files somewhere inside the web root. The web root should be deployed by your local or remote server.
Example:
Download and install MAMP.
Set your root directory as the MAMP root directory in preferences.
Now you can use your own paths -- just follow the example in the link you provided.
https://www.mamp.info/en/
Also, I'm of the opinion that it's good practice to at least use a local web server as opposed to running your website without one.
You don't need a webserver to test the code given in that example. ng-include using relative paths works fine.
However, if you really want to use a webserver for other examples/projects, depending upon your OS, you can use *AMP. where * means
W for windows
L for linux
once you have it installed, place the files in www folder. and access it in browser using http://localhost
Firstly I add my app folder under
D:\tomcat7\apache-tomcat-7.0.67-windows-x64\apache-tomcat-7.0.67\webapps
after I run tomcat server .
And run
http://localhost:8080/an/ht.htm
It is working :) Thanks #ketchupisred #Mridul Kashyap

How to render dynamic Visuals using D3.js on Google Chrome using a local desktop server?

I have managed to develop D3.js visuals on Mozilla Firefox using a local computer and no server. But if I want to develop it on Google Chrome, only static data (and not dynamic) can be rendered.By Dynamic i mean, having a Dropdown on front end and a csv at back end to pull the data from.
Run a local server.
From the command line in the directory where index.html resides, run the following python command:
python -m SimpleHttpServer
This will serve on localhost:8000 by default. If python isn't you style, there are numerous other ways that are easily google-able for you to run a local server.
For more information about how to set up a beginning dev environment, Mike Bostock writes about it here. He uses http-server from Node for his local server.

Make an absolute path works in local file

We have a web proyect in Coldfusion. All resources are linked with absolute paths, I mean, the paths in the css are like this:
.class {background:url(/folder/img/image.png);}
And the paths in the HTML are like this:
<img src="/folder/img/theimage.png"/>
I need to download the files to my local machine, make the changes and upload them again.
To see the changes, I manually remove all the slashes in the downloaded files, then write it again, but I think that should be an easier way to see the pages correctly without make those changes.
Can I put the resources folder in some place to make the absolute path find them?
If that's not the correct way, how can I "see" the files in my local machine (without a localhost) without changing the absolute path once and once again?
Do your local development on a computer with a web server that is configured to be as close to the web server you use in production as possible.
Using a virtual machine (such as VMWare or VirtualBox) makes this easier.
Most modern dev. platforms have HTTP servers that are easy to set up. My favorite has always been Python's. Running it is as simple as cding to your project directory and running one Python command. You can also easily run multiple servers concurrently on different ports.
Here are some examples with Python v. 2.7.
# run server on port 9999
> python -m SimpleHTTPServer 9999
# run server as background process on port 3333
> nohup python -m SimpleHTTPServer 3333 > /dev/null &
Python 3 has a different syntax, but same idea. See https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server

making an XML dump of a MediaWiki using dumpBackup.php

Using the MediaWiki maintenance script called dumpBackup.php I want to create an XML dump of my MediaWiki.
To do this you have to login to the server using an SSH client, I'm using Putty (Windows), but I also tried it on OSX using Terminal.
According to the MediaWiki Manual for dumpBackup.php this is done using these commands:
cd w/maintenance
php dumpBackup.php --full >d:\backup.xml
Since I am using GoDaddy hosting the last line is a bit different for me. The reason is that SSH for GoDaddy by default still uses php4 (unlike the HTTP server). For this reason my command is (assuming you are also in the maintenance folder):
usr/local/php5/bin/php dumpBackup --full >d:\backup.xml
The however, all this does for me is print everything on the screen and no file is created. Does anybody know why this is and how to make sure the file is created.
You left out the > from the original example:
php dumpBackup.php --full >d:\backup\dump.xml
The > tells the shell to redirect the output of the script to the file d:\backup\dump.xml instead of the screen.
By the way, d:\backup\dump.xml is a Windows file name. Since your server seems to be using a Unixish OS (probably Linux), you probably don't want to use that filename. However, if you don't mind having the file created in your current directory, just plain dump.xml will work fine on both Windows and *nix.
You could also try e.g. ~/dump.xml or $HOME/dump.xml (both of which create the file in your home directory) or $TMP/dump.xml (which creates it in the directory designed for temporary files, usually /tmp.) This could be useful if you don't have enough space available in the directory you installed MediaWiki in.
To see how much space you do have, try the commands df -h (which shows the amount of actual free space) and quota -vs (which shows how much of that space you're allowed to use, if that has been limited). For more help with these commands, try man df and/or man quota.

How to use GVIM to edit a remote file?

I use GVIM on Ubuntu 9.10. I'm looking for the right way to configure GVIM to be able to edit remote files (HTML, PHP, CSS) by for exemple ftp.
When i use :e scp://username#remotehost/./path/to/file i get: error detected while processing BufEnter Auto commands for "*":E472: Command failed.
When i open a file on remote via Dolphin or Nautilus, i cannot use other files with NERDTree.
Finally when i edit on remote a file via Dolphin the rights are changing to access interdit.
So how to use GVIM to edit remote files like on my localhost?
I've found running the filesystem over ssh (by means of sshfs) a better option than having the editor handle that stuff or running the editor itself over an ssh tunnel.
So you need to
apt-get install sshfs
and then
sshfs remoteuser#remotehost:/remote/path /local/mountpoint
And that will let you edit your remote files as if they were on your local file system.
To make it even smoother you can add a line to /etc/fstab
sshfs#remoteusername#remotehost:/remote/path /local/mountpoint fuse user,noauto
For some reason I find that I have to use fusermount -u /local/mountpoint rather then just umount /local/mountpoint when experimenting with this. Maybe that's just my distro.
Recently I've also noted that the mounting user must be in the fuse group. So:
sudo addgroup <username> fuse
An other popular option of course, would be to run vim (rather then gvim) inside a GNU Screen session on one machine and connect to that session via ssh from wherever you happen to be. Code along all day at work and in the evening you ssh into your office computer, reattach to your gnu screen session and pick up exactly where you left off. I used find the richer color palette to be the only thing I really missed from gvim when using vim, but that can actually be fixed thanks to a fork of urxvt that will let you customize the entire 256 position color palette, not just the 16 first positions of the palette that most terminal emulators will let you customize.
There is one way and that is using the remote host's copy, using SSH to forward the X11 client to you, like so:
user#local:~/$ ssh -X user#host
...
user#host:~/$ gvim file
The latter command should open gvim on your desktop. Of course, this relies on the remote host having X11 / gnome / gvim installed in the first place, which might not be the solution you're looking for / an option in your case.
Note: X11 forwarding can be a security risk.
In order for netrw to work seamlessly, I believe you need to not be in compatibility mode.
Try
:set nocompatible
then
:edit scp://host/path/to/file
Try this
:e scp://username#remotehost//path/to/file
Note that the use of // is intentional after remotehost it gives the absolute path of your file
:)
http://www.celsius1414.com/2009/08/19/how-to-edit-remote-files-with-local-vim/
The vim tips wiki has an article on this, Editing remote files via scp in vim.
EDIT: Key authentication is not necessary for opening files over ssh. Vim will prompt for password.
It would be useful to note if netrw.vim was loaded by vim when it started.
:echo exists("g:loaded_netrwPlugin")
For opening files over ssh, you need your local machine's public key in the server's authorized keys. Following help section in vim documentation explains it pretty well.
:help netrw-ssh-hack
Quick way to export public key would be by using ssh-copy-id (if available).
ssh-copy-id user#host
And have a look at netrw documentation for network file editing over other protocols.
:help netrw
HTH.
According to the docs BufEnter is processed after the file has been read and the buffer created, so my guess is that netrw successfully read the file but you have a plugin that assumes the file is on the local filesystem and is trying to access it, e.g. to run ctags.
Try disabling all your plugin scripts except the default Vim ones, and then editing the file.
Also, try editing a directory to see if netrw can read that - you need to put the / on the end so that netrw knows it is a dir.
About your command, :e scp://username#remotehost/./path/to/file : note that with netrw, scp is taken relative to your home directory on that remote host. To avoid home-relative pathing, drop that "."; ie. :e scp://username#remotehost//path/to/file .
to accomplish this on windows download/install the Dokan library and Dokan SSHFS, which are the first and last links on this page.
I didn't think you were going to be able to directly edit a remote file using GVIM running locally. However, as others have pointed out, this is defintiely possible. This looks very interesting; I will check this out. I will leave the rest of my post up here, in case it is useful to anyone else, as an alternative method. This method will work even if you don't have SSH access to the file (ie, you only have FTP, or S3, or whatever).
You may get that effect, though, by tying GVIM into a graphical file transfer application. For example, on OS X, I use CyberDuck to transfer files (FTP, SFTP, etc). Then, I have it configured to use GVIM as my editor, so I can just double-click on a file in the remote listing, and CyberDuck will download a copy of that remote file, and open it in GVIM. When I save it in GVIM, CyberDuck uploads the file back to the remote host.
I'm sure that this functionality is not unique to CyberDuck, and is probably present in most nicer file transfer utilities.