apify-docs icon indicating copy to clipboard operation
apify-docs copied to clipboard

'Running a web server' should go under Tutorials

Open honzajavorek opened this issue 1 year ago • 1 comments

The page Running a web server on the Apify platform is standalone and seems to be a specific solution to a very specific problem. IMHO it is a how-to guide and should go under Tutorials.

(Aside the fact that it is also platform-specific and long-term might not even belong to the Academy as we envision it.)

honzajavorek avatar Apr 26 '24 15:04 honzajavorek

And readers suggest changes to this page:

Could be useful to suggest to start from the crawlee-puppeteer-chrome template. The code is outdated. The line await Actor.init(); should be added to the beginning of the file. The line const browser = await Actor.launchPuppeteer(); should be replaced with const browser = await launchPuppeteer(), with the import import { launchPuppeteer } from "crawlee";. The POST URL should be relative.

import { Actor } from "apify";
import express from "express";
import { launchPuppeteer } from "crawlee";

await Actor.init()

[...]

app.get("/", (req, res) => {
    [...]
        <form method="POST" action="/add-url">
    [...]
});

app.post("/add-url", async (req, res) => {
    const { url } = req.body;
    console.log(`Got new URL: ${url}`);

    // Start chrome browser and open new page ...
    const browser = await launchPuppeteer()
    [...]
});

[...]

honzajavorek avatar Apr 26 '24 16:04 honzajavorek