T
T
tnsaturday2018-05-11 01:14:50
Python
tnsaturday, 2018-05-11 01:14:50

Search web application architecture?

In the course of implementing my task, I wrote a parser that bypasses sites, scrapes the necessary information, and writes the whole thing into a JSON file, which I then work with. I want to bring this application online and significantly expand its functionality, of course, first of all towards the front-end, since it is naive to think that someone will use the application with a command line interface.

The question arises of how best to organize all this in terms of architecture, so that it spins as quickly as possible on cheap hosting. The use case is similar to Google's live server:
1. The user enters a query in the search bar.
2. After pressing the enter button, get the search results without reloading the page.

Now questions:

1. SQL vs NoSQL vs JSON.
At the moment I have python scripts that open, write and read from a json file. How much time wasted is json file lookup compared to database lookup? That is, it’s probably right to add all this to the database, it’s just that on my use cases (an array of 700-800 objects, 5-6 key-value pairs of the form of unicode strings and regular urls), even on a necronote 12 years old, this all works instantly, but in multi-user conditions environment, how will all this work, taking into account the GIL of the python lock and how files are opened for reading in Linux?

2. PHP vs. Python.
It so happened historically that I use Python as a general purpose language, and I write the backend in PHP. I'd like to avoid using two languages ​​and stay with Python if possible. I don't know Django at all and here's the question: PHP is great for web development without frameworks, especially in the case of a simple application like in this case: one page (no templating needed), no authentication (accordingly, there is no fuss with users with access rights, emails , registrations, etc.), basically the whole code:
$search = $_POST['search_request'];
$conn = new mysqli($servername, $username, $password, $dbname);
$sql = "SELECT * FROM data WHERE title='" . $search. "'";
$result = mysqli_query($conn, $sql);
echo $page;
I started smoking Django and there is quite a lot of everything, this is a huge full-fledged MVC (although for some reason they themselves call it MTV, what is the difference I have not yet understood) a framework and there are quite a lot of whistles and fakes. Is there a way to write a web application in Python without a framework, in PHP style? Given that my functionality is very simple: one POST request, a couple of mysql queries, is it really worth starting a framework for this, is it a monstrous overhead?

3. AJAX
I want to set up the frontend so that the search works without a reboot. As I understand it, this is done by AJAX. They used to do it with jQuery, now fetch and axios seem to be fashionable. How is this best implemented?

Please give me advice on how to work on such a project. I welcome tutorials, best practices and all sorts of how-to. How is this generally done in practice?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2018-05-11
@sim3x

Django + postgresql + shinxsearch
It makes no sense to "save" and think that you have a "simple" application - use a framework
But judging by the text of the question, you should start with simpler tasks and where there are full-fledged step-by-step guides

P
planc, 2018-05-11
@planc

if there is a json file in which there is no secret information, then let js work with it right away
I don't know Django at all
flask.pocoo.org
https://habr.com/post/346306/
$sql = "SELECT * FROM data WHERE title='" . $search. "'";
https://ru.wikipedia.org/wiki/%D0%92%D0%BD%D0%B5%D...
3. AJAX
the whole project is an adventure for 30 minutes, take the usual js + fetch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question