HTTP Server in iOS to list files Documents directory

489 views Asked by At

I am trying to create an HTTP Server inside my iOS application, to develop something like Xender application. Right now I Succeed to setup HTTP Server inside my Application and hosting any HTML file there, that can be loaded on another Device/System using IP and Port.

But, I want to Link that HTML to my application database to populate data on that HTML file, followed by making it dynamic so that It can be opened from another device or system.

Ultimately, I need to Query on SQLITE database of application from HTML file, Is there any way to do such thing?

Can I connect SQLITE to frontend of HTML? In case of Web apps these things can be done using any server side scripting languages like PHP, by connecting with Databases like MySQL. But, Here My case is HTML and Sqlite.

EDIT

I found Is it possible to access an SQLite database from JavaScript? . but this is all about Client side local storage, but I think in my case its on Server side SQLITE.

1

There are 1 answers

4
Julian F. Weinert On BEST ANSWER

You have to create template HTML files and provide a set of variables for it. Then, when the file is requested in your server, you load it into memory.

Now you do some RegEx magic to get the query parameters, do your SQL stuff and then replace the corresponding variables in your HTML string and finally serve it to the client.

Your would need to define your own non-logical "scripting" language that is able to tell your application what data is requested and where to output possibly returned data.

I think this is quite hard work and you should possibly try to find a better solution that is probably already done by others.

EDIT

You could use Node.js and this interpreter but it's not maintained anymore. But their might be similar projects.

EDIT II

I've found the neu.Node, which sounds quite promising. They haven't done anything in 4 months, but they seem to be well organized and documented.