N
N
n1ksON2021-01-11 19:20:11
Node.js
n1ksON, 2021-01-11 19:20:11

How to run code on a remote server?

I'm doing front-end development, but I need partial back-end work in one project.
Please tell me from A to Z what exactly needs to be done.
It is necessary to send the resulting image to the server and use tesseract.js to read the text from it and then send the result back to the front (now the image is processed on the front, so it takes an enormously long time). Ideally, you need some very simple server that can be accessed via API with a blob64 image and get a response with text.
I have two options: 1) write a function on some cloud server, like firebase. 2) write your own node.js server, which is much more difficult

Answer the question

In order to leave comments, you need to log in

4 answer(s)
I
Israfil22, 2021-01-11
@n1ksON

Yes, in fact, creating a server on a node is an extremely simple procedure.
The REST API on Express is written in just an hour, along with the analysis of all the material.
The only thing you'll have to deal with is HTTPS if you're renting a car.
I hope that you are already familiar with the concepts of VPS / VDS and do not need to explain where to host.
If you plan to greatly expand your backend server, then, of course, you need your own private server.
For one to a dozen endpoints, try Heroku.
"Hello world" from the official documentation - couldn't be easier)
https://expressjs.com/en/starter/hello-world.html
However, think about the real benefits. As mentioned in the comments above, packet forwarding time can be much longer than the operation time.

D
Dimonchik, 2017-04-15
@Georgy123

here you check
https://www.artlebedev.ru/tools/decoder/
CP1252 - CP1251
find the original, decode

A
Alexander, 2017-04-14
@bergsoft

import json
import codecs

def write_json(data):
    with codecs.open('your_file.txt', 'w', encoding='utf-8') as file:
        json.dump(data, file, indent=2, ensure_ascii=False)

A
Alexander, 2017-04-24
@Survtur

I did not understand where the error is, but judging by the code, it may be in the place where the json response was received.

#посмотреть угаданную автоматом кодировку
print(r.encoding)       

# установить реальную кодировку (какая там - я не знаю, cp1251 написал просто так)
r.encoding = 'cp1251'   

text = r.text
data = json.loads(text)
write_json(data)

Although maybe you have an error in json.dump? In this case, you most likely have an encoding of the output file that is not utf-8 and you just need to
with open('posts.json', 'w', encoding='utf-8') as file:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question