Skip to content
Minimalistic webperf client mainly running on PythonAnywhere.com
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dbase Removed MySQL Dec 29, 2019
.gitignore Removed MySQL Dec 29, 2019
LICENSE Create LICENSE Dec 29, 2019
README.md Update README.md Jan 1, 2020
SAMPLE-config.py Removed MySQL Dec 29, 2019
checks.py Removed MySQL Dec 29, 2019
default.py Removed MySQL Dec 29, 2019
models.py Removed MySQL Dec 29, 2019
requirements.txt Removed some Flask and MySQL Dec 29, 2019

README.md

Webperf Core

Minimalistic client mainly running on PythonAnywhere.com, accessing different websites, or web-APIs, and scraping them.

The tests included in the first version are:

  • Google Pagespeed Insights API
  • Testing the 404 page and status code
  • Validating the HTML code against W3C
  • Validating the CSS code against W3C
  • Users’ integrity test against Webbkoll, provided by Dataskydd.net

Get started with webperf_core

Here are some suggestions on how to get started with the tests on your own computer. Actually, it is even easier to run the tests on a cloud environment such as PythonAnywhere - $ 5 / month - then the technical environment is ready to just upload the files.

You download the code itself from GitHub - webperf_core and place it in a good place on your computer.

Adjust the source code

There are two files that you need to adjust:

  • SAMPLE-config.py needs to be renamed to config.py
  • In the dbase folder, the SAMPLE-dbase.sqlite file should be renamed to dbase.sqlite The reason for this is because if you download a new version of the code, your settings or data should not be overwritten by accident.

Another thing you need to do is to open the config.py file and change one thing. The line that looks like the following is incomplete:
googlePageSpeedApiKey = “”
Between the quotation marks, enter your Google Pagespeed API key. See the following header for how to do this.

Google Pagespeed API key

You can choose to ignore the Google Pagespeed API. In this case, put a hashtag # in front of the following line in default.py:
testsites(test_type=0)
So it looks like this:
# testsites(test_type=0)

Google Pagespeed requires an API key. You can get one like this:

  1. Go to Google Cloud Platform.
  2. Search for Pagespeed Insights API.
  3. Click on Credentials (you may need to create a project first, if you do not already have one).
  4. Click + Create Credentials, then API key
  5. In the dialog the key now appears below Your API key, it can look like this AIzaXyCjEXTvAq7zAU_RV_vA7slvDO9p1weRfgW

That code is your API key, that you should put in the config.py file in the source code, between the quotation marks on the line where you find googlePageSpeedApiKey.

Running the code

You need to go through the following steps before you run the code:

  1. If you do not have Python installed, start with downloading Python (which you can ignore if you run on PythonAnywhere).
  2. Open the Terminal (Macos & Linux) or Command Prompt (Windows).
  3. Navigate to where you downloaded (and unpacked) the source code. If you don’t know how to navigate in Terminal/CMD, read the Windows guide or under Step 5 for Mac / Linux.
  4. Type the following command and hit Enter:
    pip install -r requirements.txt
    Then some Python extensions will be installed.
  5. Start the program with the following command and press Enter:
    python default.py

Now it will begin testing.

Adjust the database

If you have not changed anything in your database, it is webperf.se that will be tested. To change the database, you can download DB Browser for SQLite. However, it does not seem to be available on Linux.

You can add a bunch of websites. Open the database, go to the sites table, add a new line / record with each website’s address and title. The test results are added to the table site_tests when you run the code.

Good to know about the database:

  • A site identity is called id in the sites table, which refers to site_id in the test results in sitetests.
  • most_recent in sitetests is a filter to get the latest tests for each website, select 1 to only get the most recent tests.

If you don’t know the query language SQL for databases, there is a good introduction to W3Schools. It is with SQL that you can retrieve results from the database, calculate averages and much more.

Are you getting error messages?

It is often worthwhile to google the error messages you get. If you give up the search then you can always check if someone on our Slack channel have time to help you, but don’t forget to paste your error message directly in the first post. Or, if you think your error are common for more people than yourself, post an issue here at Github.

What you are allowed to do with this code / repo

The license used is the MIT license. This means that you can do whatever you want with the source code, including using it in commercial software and contexts. However, there is no guarantee or liability for the code.

Do you want to contribute?

You can contribute here at Github. By checking the code, trying the documentation, suggesting new tests, among other things.

Hosting webperf_core in the cloud

You can’t perform that action at this time.