syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me

Question:
How to use Meteor to serve a cat jpg?

I use this simple use-case as a description of how to use Meteor to serve static content.

I start by login to my test account:
ssh ann@localhost
Then I use a call to curl to run an installation script:
curl https://install.meteor.com/ | sh
The script runs until it finds that ann is not in the sudoers file.

I am happy with this because I do not want this script to run commands on my laptop as root.

The script gives me some good info:

ann@envy:~$ 
ann@envy:~$ curl https://install.meteor.com/ | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6119    0  6119    0     0   5006      0 --:--:--  0:00:01 --:--:--  5007
Downloading Meteor distribution
######################################################################## 100.0%

Meteor 1.0.5 has been installed in your home directory (~/.meteor).
Writing a launcher script to /usr/local/bin/meteor for your convenience.
This may prompt for your password.
[sudo] password for ann: 
ann is not in the sudoers file.  This incident will be reported.

Couldn't write the launcher script. Please either:

  (1) Run the following as root:
        cp "/home/ann/.meteor/packages/meteor-tool/1.0.45/mt-os.linux.x86_64/scripts/admin/launch-meteor" /usr/bin/meteor
  (2) Add "$HOME/.meteor" to your path, or
  (3) Rerun this command to try again.

Then to get started, take a look at 'meteor --help' or see the docs at
docs.meteor.com.
ann@envy:~$ 
ann@envy:~$ 
I edited ~ann/.bashrc and added $HOME/.meteor to PATH using syntax like this:

if [ -e $HOME/.meteor ]; then
  export PATH="$HOME/.meteor:$PATH"
fi
Next I created a meteor application:
meteor create catjpg1
Then I did this:
cd catjpg1
mkdir public
cd    public
Then I got a cat jpg file from wikipedia:
curl http://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Cat_poster_1.jpg/800px-Cat_poster_1.jpg > cat.jpg
Next I added an img-element to:
~ann/catjpg1/catjpg1.html
syntax:
<img src='cat.jpg'>
Then I started the meteor application on my laptop:
ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ cd ~ann/catjpg1
ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ cat catjpg1.html 
<head>
  <title>catjpg1</title>
</head>

<body>
  <h1>Welcome to Meteor!</h1>

  {{> hello}}

<img src='cat.jpg'>

</body>

<template name="hello">
  <button>Click Me</button>
  <p>You've pressed the button {{counter}} times.</p>
</template>
ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ meteor
[[[[[ ~/catjpg1 ]]]]]

=> Started proxy.
=> Started MongoDB.
=> Started your app.

=> App running at: http://localhost:3000/
It worked!

Next I 'deployed' the app:

=> App running at: http://localhost:3000/
 ctrl-c

ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ meteor deploy catjpg1
To instantly deploy your app on a free testing server, just enter your email
address!

Email: ann11@yahoo.com
Deploying to catjpg1.meteor.com.
Now serving at http://catjpg1.meteor.com

You can set a password on your account or change your email address at:
https://www.meteor.com/setPassword?JJgYDcZw46K

ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ 
Then I verified that the deployed app was serving my jpg file:

ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ curl http://catjpg1.meteor.com/cat.jpg > /tmp/cat.jpg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 83859  100 83859    0     0   165k      0 --:--:-- --:--:-- --:--:--  165k
ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ 
ann@envy:~/catjpg1 $ 
Then I loaded http://catjpg1.meteor.com into my browser and I saw some cats!

syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me