hi raymond,

your idea of including other files is already done.
there is a function "script" (see "gas,js") which includes other files. that how i want to support different "applications". on example is "notes". in "apps/notes.js" i implemented the ajax backend, in "www/Notes/*" i implemented the frontend.

the part you've written about loading xml files (contacts.xml) is solved like this (again, see gas.js):
   var config = new XML(new File("server.xml").read());
   print(config.port+"\n");

a simple scheduler is also already implemented (again, see gas,js :-):
   // print "from timer" to console in 10 secs
   addTimer(10, "print('from timer\\n');");

i also implemented a database sample for directly editing databases via the browser (see SQLiteBrowser in the source zip). but its still not finished (only running in MSIE correctly !) there you can play with databases: select a database / select a table / edit values just with a dblclick, change the value, hit return...

cu, gg


Raymond Irving schrieb:
This is very very sweet :)

Many thanks for sharing Greschenz. I would love to see
this project mature. Maybe something like a ThinClient
webserver with Javascript as the backend so we could
write lovely web apps with AJAX support that offers
database like features? Could it also run on
Thinstation with some attached storage? Wow!
Here's some other ideas:

* Make it possible to include external classes or
files, for example include('myclass.jsp')
* add some build it object to make it easier to do
stuff inside the server. Example Mail, File, Scheduler

var mail = new Mail()
mail.to = '[EMAIL PROTECTED]';
mail.from = '[EMAIL PROTECTED]'
mail.subject = 'Hello';
mail.send()

var f = new File('contacts.xml');
var xml = f.readAll();

var sch = new Scheduler();
if(!sch.exists('MyImporter')) {
   sch.setName('MyImporter');
   sch.setInterval(30); // every 30 minutes
   sch.execute('imports.jsp');
   sch.save();
}


Just my 2 cents.
__
Raymond Irving


__
Raymond Irving

--- Günter Greschenz <[EMAIL PROTECTED]> wrote:

Hi,

the reasons why i did this:
1) i wanted to have a simple webserver to get my son
involved in programming an online game, and he knows already a
little bit javascript
2) my hobby is programming in c++ and javascript,
but at work i have to code in c#, so i just wanted to have some fun :-)

i think its no a new idea, ive seen some webservers
using javascript as backend language, but everything i found was to complicated to install/use or to complicated to port to a new hw-platform (i want to run it on my linksys-nslu2 with ftpd to my topfield hd-vcr to program the recordings via web).
and i like sqlite very much and no webserver i found
had this combination.
if you look at my code, you see that i just use
*) sqlite
*) the javascript-engine from mozilla (very
advanced: js v1.7 including xml support...),
*) some glue code to access sqlite and a simple http
server from js (only one file: gas.cpp)

the trick between js and sqlite is like yours: every
sql statement executed returns a 2-dim array...
one thing is maybe iteresting: the class "DBItem".
its a kind of (very simple) or-mapper.
it maps the properties of a javascript-object to the
columns of a table. here is a code example:

    var db = new Database("user.sdb");
    db.exec("create table if not exists user (id
integer primary key autoincrement, name varchar unique, pwd varchar,
test varchar)");
    var user = new DBItem(db, "user");
    user._name = "Guenter";
    user._pwd = "FooBar1234567890";
    user._test = "blubb";
    user.flush();
    var id = user._id;
    var user = new DBItem(db, "user", id);
    print("name="+user._name+"\n");
    //db.exec("delete from user where id="+id);

if you are still curious (or anyone else ?), i can
send you the actual source by mail. :-)

btw: i had a look into your http-source: looks nice,
but its maybe to complicated to implement my features like
http-multipart-posts.

cu, gg





John Stanton schrieb:
The multi-threaded application/www server I
described requires no
threading involvement from the application
programmer. That
programmer uses SQL, HTML, Javascript and the
application language we
call MUV. Think about it, when you use Apache you
don't have to be
aware of its internal threading.

The only significant synchronisation element is to
do with multiple
users of Sqlite, and that is handled transparently
to the application
programmer.

What I was curious about was your statement that
you used Javascript
as a backend. Do you have a novel idea there?
For example my
application language will, inter alia, populate
Javascript arrays from
an SQL statement.  Do you have any such features
or something more
ingenious? (I still cannot get access to your
server).
My application server runs on Win98, Win2000/XP,
Linux, AIX 4.2 and
5.3.  The executive, fileserving, compression and
CGI components are
realised in less than 20K of code.  HTML V2 is
implemented.
There are some old fragments of this program at http://www.viacognis.com/muvm. If you are
interested I can dig out
the current code and let you have it.


Günter Greschenz wrote:
Hi,

normally i like multithreading, but in this case
i like the simple
approach (at least for rendering the pages),
because as application
programmer (the guy who will develop the apps in
javascript) its much
easier if you dont have to think about locks,
racing conditions and
other pitfalls. and the rendering itself is
(depending on what you
do, of course) fast enough for me (simple pages
need <10ms !). I want
to multithread the upload to the client after all
work is done.
in my current implementation the complete server
is blocked until the
download is finished. in my logfiles i have
entries with 25 minutes
(see
"http://greschenz.dyndns.org/logsByTime.html";) !!!
thats really
unacceptable !
could you mail me some samples howto multithread
portable (linux &
win32) ?

cu, gg


John Stanton schrieb:

Gunter,

I recently wrote a multi-threaded portable web
server in simpl ANSI
C. It uses Win32 threads or pthreads.  It caches
threads and re-uses
them on a most recently used basis.  Efficiency
is obtained by using
TransmitFile (Win32) or sendfile (Unix).

The logic is simple for an efficient,
multi-threaded www server.
An added bonus of mutli-threading is that it
takes advantage of the
ability of a browser to open multiple concurrent
connections and
persistent connections.

My WWW server is set up as an application
server, with embedded
Sqlite and an embedded byte-coded metalanguage
used to define DHTML
pages.  An associated compiler produces the byte
code. By using
compiled byte code the overhead of interpreting
a script-type
language is avoided.

Günter Greschenz wrote:

Hi,

yes i know, the problem is, its single-threaded
(because of
protability), so if anyone starts a download
with a slow
connection, the server is blocked for other
connections.. im still
thinking about this problem... single-threading
whle rendering th
pages and multithreading for sending them to
the clients, or maybe
async socket writes (is this possible in linux
?)
but i've seen (in the logs :-) a lot of people
are interested. its
funny to sit at the console at home and see the
log messages when
anyone comes by...
at the moment its just an alpha-version... but
if i have more time
(or maybe anyone helps me) it will improve !
the server itself is an i386-linux at ~ 300mhz,
so dont expect too
=== message truncated ===


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------


Reply via email to