Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: http server simulation? #39

Closed
fatshotty opened this issue Aug 29, 2012 · 12 comments
Closed

question: http server simulation? #39

fatshotty opened this issue Aug 29, 2012 · 12 comments

Comments

@fatshotty
Copy link

is it possibile to have an http server simulation?

thanks

@zcbenz
Copy link
Contributor

zcbenz commented Aug 30, 2012

I don't understand your question, isn't node.js designed for http server? Why simulation?

@gasolin
Copy link

gasolin commented Aug 30, 2012

I probably had blocked with the same issue, the current available demos does not help newbie with limit node.js knowledge.

The demo package.json load html pages with file:// prefix.

It will be better to provide a simple demo that shows how to configure to run web pages with http server in node-webkit.

the demo should answer those questions

  1. I have to write a server.js by myself (I think the answer is yes) ?
  2. then, where should i specify the .js in package.json?
  3. and, what format should i indicate the default url in package.json.
  4. possible modules or snippet that help newbie quickly pick up node-webkit (maybe a static web file server snippet is a good start https://gist.github.com/701407)

@zcbenz
Copy link
Contributor

zcbenz commented Aug 30, 2012

Do you mean something like this?

<html>
<body>
<script>
  var http = require('http');

  http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('hello');
  }).listen(10086);
</script>
</body>
</html>

@gasolin
Copy link

gasolin commented Aug 30, 2012

Most node.js doc says use command

$ node [filename].js

to run the node.js script.

what is the correspondent way to trigger a node.js script/application in node-webkit?
Do we need to wrap node.js code into [filename].html?

I can't get any visual result with above code on mac os 10.7.

thanks

@zcbenz
Copy link
Contributor

zcbenz commented Aug 30, 2012

Maybe you have misunderstood node-webkit's purpose.

node-webkit is not used to execute node.js scripts, but to show HTML pages which contains node.js code. It's strange to run a http server in node-webkit.

@zcbenz zcbenz closed this as completed Aug 30, 2012
@rogerwang
Copy link
Member

we'll support run unwrapped node.js code directly, which I think is useful. see issue #36

@rogerwang
Copy link
Member

@gasolin , with @zcbenz 's code you should have a http server running, though you won't see anything visual, as expected. Just try to access the http server from your browser.

@fatshotty
Copy link
Author

Uhm, sorry the ambigous question...
Node-webkit shows html page containing nodejs code, right.
I mean, can html pages be shown via http request simulating an http server?
Uhm. The same as http://appjs.org

Thanks

@rogerwang
Copy link
Member

@fatshotty , the similar thing should be possible after we fix #36.

@zcbenz
Copy link
Contributor

zcbenz commented Aug 30, 2012

I'm still not very sure about what you want.

To send request and replace part of the web page, you can use jQuery.ajax(). Or you can send request and use document.write to show contents.

To just show a URL, specify the URL in the main field of the package.json or use window.open.

To use the traditional node.js way of showing web pages, e.g. use template engines like Jade, HMAL, just use them, you don't need to emulate http request.

Or do you mean HTML5 history API? Which show different contents according to current URL.

I think you just go the wrong of writing apps, a HTML app can need nothing of node.js stuff.

@zcbenz
Copy link
Contributor

zcbenz commented Aug 30, 2012

And it's wrong to use the appjs way to write HTML apps, if you do, you'll lose the chance of moving your apps to other platforms forever.

@fatshotty
Copy link
Author

understood, clear ;)

thanks everybody

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants