0

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.

Community
  • 1
  • 1
Mrug
  • 4,963
  • 2
  • 31
  • 53

1 Answers1

1

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.

Julian F. Weinert
  • 7,474
  • 7
  • 59
  • 107
  • Do You mean to keep that data in any textual data in some particular format like XML or JSON ? – Mrug Jun 08 '15 at 09:52
  • You write HTML like: `get_data('table', ...)` and when a client requests that file, you read it into memory (you must have done this already) and RegEx search for `get_data(...)` and replace it with the actual data after querying the DB for the values in the braces. – Julian F. Weinert Jun 08 '15 at 09:55
  • 1
    You are basically creating a language like PHP but without the local stuff (if, for, case, ...). You clearly see, this can be a quite challenging task, especially the conceptual aspects. But hey! When you create something amazing nobody never did befor, you can go OpenSource and make amazing success with it ;) – Julian F. Weinert Jun 08 '15 at 09:58
  • Thanks @Julian, It will be really very helpful – Mrug Jun 08 '15 at 12:32
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/79958/discussion-between-mrug-and-julian). – Mrug Jun 08 '15 at 13:48